www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - rdmd problem

reply Comrad <comrad.karlovich gmail.com> writes:
I have a strange problem with rdmd:
 cat test.d
import std.stdio; void main() { writeln("Hello, world with automated script running!"); } -------------------- This hangs, but if I remove compile options it does work. Overall it doesn't work with any compiler options.
 dmd --version
DMD64 D Compiler v2.085.0 Copyright (C) 1999-2019 by The D Language Foundation, All Rights Reserved written by Walter Bright
 lsb_release -a
No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 14.04.5 LTS Release: 14.04 Codename: trusty
 gcc --version
gcc (Ubuntu 4.9.4-2ubuntu1~14.04.1) 4.9.4 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Apr 01 2019
next sibling parent reply Seb <seb wilzba.ch> writes:
On Monday, 1 April 2019 at 11:10:06 UTC, Comrad wrote:
 I have a strange problem with rdmd:
 cat test.d
import std.stdio; void main() { writeln("Hello, world with automated script running!"); } -------------------- This hangs, but if I remove compile options it does work. Overall it doesn't work with any compiler options.
 dmd --version
DMD64 D Compiler v2.085.0 Copyright (C) 1999-2019 by The D Language Foundation, All Rights Reserved written by Walter Bright
 lsb_release -a
No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 14.04.5 LTS Release: 14.04 Codename: trusty
 gcc --version
gcc (Ubuntu 4.9.4-2ubuntu1~14.04.1) 4.9.4 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Shebang only supports one argument on your OS. See e.g. https://unix.stackexchange.com/questions/63979/shebang-line-with-usr-bin-env-command-argument-fails-on-linux Please use the "Learn" forum the next time.
Apr 01 2019
parent Seb <seb wilzba.ch> writes:
On Monday, 1 April 2019 at 11:23:23 UTC, Seb wrote:
 On Monday, 1 April 2019 at 11:10:06 UTC, Comrad wrote:
 [...]
Shebang only supports one argument on your OS. See e.g. https://unix.stackexchange.com/questions/63979/shebang-line-with-usr-bin-env-command-argument-fails-on-linux Please use the "Learn" forum the next time.
To extend on this: as this is a well-known limitation, rdmd has the --shebang switch that can be used to indicate to rdmd to split the arguments itself.
Apr 01 2019
prev sibling next sibling parent reply Andre Pany <andre s-e-a-p.de> writes:
On Monday, 1 April 2019 at 11:10:06 UTC, Comrad wrote:
 I have a strange problem with rdmd:
 cat test.d
import std.stdio; void main() { writeln("Hello, world with automated script running!"); } -------------------- This hangs, but if I remove compile options it does work. Overall it doesn't work with any compiler options.
 dmd --version
DMD64 D Compiler v2.085.0 Copyright (C) 1999-2019 by The D Language Foundation, All Rights Reserved written by Walter Bright
 lsb_release -a
No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 14.04.5 LTS Release: 14.04 Codename: trusty
 gcc --version
gcc (Ubuntu 4.9.4-2ubuntu1~14.04.1) 4.9.4 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I am not sure wheter compiler arguments works at the shebang line. If it works there might be the issue, that the file is passed first to rdmd and then the compiler argument. Arguments after the file name are handled as application arguments and passed to the application. What definitely works is using dub and single package file https://dub.pm/advanced_usage You can define the versions in the json/sdl section. Kind regards Andre
Apr 01 2019
next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 4/1/19 7:23 AM, Andre Pany wrote:
 I am not sure wheter compiler arguments works at the shebang line.
Yah, that's the problem. I added the option --shebang (https://dlang.org/rdmd.html) for that reason, OP can you please try that?
Apr 01 2019
parent reply Comrad <comrad.karlovich gmail.com> writes:
On Monday, 1 April 2019 at 18:27:41 UTC, Andrei Alexandrescu 
wrote:
 On 4/1/19 7:23 AM, Andre Pany wrote:
 I am not sure wheter compiler arguments works at the shebang 
 line.
Yah, that's the problem. I added the option --shebang (https://dlang.org/rdmd.html) for that reason, OP can you please try that?
So... I was able finally to make it work:
 cat test.d
import std.stdio; void main() { writeln("Hello, world with automated script running!"); } ------------------------------------ This does work. But!!! The documentation have to be changed, because the recommended way to start the script is through `env` and it doesn't help at all. Maybe I'm stupid, but it took for me some time to understand such an obvious (like it appeared to be later) thing.
Apr 05 2019
parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 4/5/19 8:20 AM, Comrad wrote:
 This does work. But!!! The documentation have to be changed, because the 
 recommended way to start the script is through `env` and it doesn't help 
 at all.
Yes, these are conflicting. Can you please make the documentation change?
Apr 05 2019
prev sibling parent reply Comrad <comrad.karlovich gmail.com> writes:
On Monday, 1 April 2019 at 11:23:43 UTC, Andre Pany wrote:
 On Monday, 1 April 2019 at 11:10:06 UTC, Comrad wrote:
 I have a strange problem with rdmd:
 cat test.d
import std.stdio; void main() { writeln("Hello, world with automated script running!"); } -------------------- This hangs, but if I remove compile options it does work. Overall it doesn't work with any compiler options.
 dmd --version
DMD64 D Compiler v2.085.0 Copyright (C) 1999-2019 by The D Language Foundation, All Rights Reserved written by Walter Bright
 lsb_release -a
No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 14.04.5 LTS Release: 14.04 Codename: trusty
 gcc --version
gcc (Ubuntu 4.9.4-2ubuntu1~14.04.1) 4.9.4 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I am not sure wheter compiler arguments works at the shebang line. If it works there might be the issue, that the file is passed first to rdmd and then the compiler argument. Arguments after the file name are handled as application arguments and passed to the application. What definitely works is using dub and single package file https://dub.pm/advanced_usage You can define the versions in the json/sdl section. Kind regards Andre
Sorry, the documentation doesn't allow me to understand easily, how to use it without additional pain. The link you gave doesn't describe a clear method for those, who never used dub before. Anyway... I was able to solve my problem in a convenient for me Thank you anyhow!
Apr 05 2019
parent reply Andre Pany <andre s-e-a-p.de> writes:
On Friday, 5 April 2019 at 12:27:25 UTC, Comrad wrote:
 On Monday, 1 April 2019 at 11:23:43 UTC, Andre Pany wrote:
 On Monday, 1 April 2019 at 11:10:06 UTC, Comrad wrote:
 [...]
I am not sure wheter compiler arguments works at the shebang line. If it works there might be the issue, that the file is passed first to rdmd and then the compiler argument. Arguments after the file name are handled as application arguments and passed to the application. What definitely works is using dub and single package file https://dub.pm/advanced_usage You can define the versions in the json/sdl section. Kind regards Andre
Sorry, the documentation doesn't allow me to understand easily, how to use it without additional pain. The link you gave doesn't describe a clear method for those, who never used dub before. Anyway... I was able to solve my problem in a convenient for me Thank you anyhow!
No problem:) Create a file sample.d with following content /+ dub.sdl: name "sample" versions "test" +/ void main() { import std.stdio : writeln; writeln("Hello, World!"); } You can start it with "dub sample" or if you add the executable flag with "./sample.d". With recent dub version you can name the file even without the .d extension and just start it with "./sample". Kind regards Andre
Apr 05 2019
parent Seb <seb wilzba.ch> writes:
On Friday, 5 April 2019 at 12:46:18 UTC, Andre Pany wrote:
 On Friday, 5 April 2019 at 12:27:25 UTC, Comrad wrote:
 [...]
No problem:) Create a file sample.d with following content /+ dub.sdl: name "sample" versions "test" +/ void main() { import std.stdio : writeln; writeln("Hello, World!"); } You can start it with "dub sample" or if you add the executable flag with "./sample.d". With recent dub version you can name the file even without the .d extension and just start it with "./sample". Kind regards Andre
Also, in more recent versions of dub the "name" field got optional as well and will be automatically inferred if not set.
Apr 05 2019
prev sibling next sibling parent Andre Pany <andre s-e-a-p.de> writes:
On Monday, 1 April 2019 at 11:10:06 UTC, Comrad wrote:
 I have a strange problem with rdmd:
 cat test.d
import std.stdio; void main() { writeln("Hello, world with automated script running!"); } -------------------- This hangs, but if I remove compile options it does work. Overall it doesn't work with any compiler options.
 dmd --version
DMD64 D Compiler v2.085.0 Copyright (C) 1999-2019 by The D Language Foundation, All Rights Reserved written by Walter Bright
 lsb_release -a
No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 14.04.5 LTS Release: 14.04 Codename: trusty
 gcc --version
gcc (Ubuntu 4.9.4-2ubuntu1~14.04.1) 4.9.4 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I am not sure wheter compiler arguments works at the shebang line. If it works there might be the issue, that the file is passed first to rdmd and then the compiler argument. Arguments after the file name are handled as application arguments and passed to the application. What definitely works is using dub and single package file https://dub.pm/advanced_usage You can define the versions in the json/sdl section. Kind regards Andre
Apr 01 2019
prev sibling parent Jonathan Marler <johnnymarler gmail.com> writes:
On Monday, 1 April 2019 at 11:10:06 UTC, Comrad wrote:
 I have a strange problem with rdmd:
 cat test.d
import std.stdio; void main() { writeln("Hello, world with automated script running!"); } -------------------- This hangs, but if I remove compile options it does work. Overall it doesn't work with any compiler options.
 dmd --version
DMD64 D Compiler v2.085.0 Copyright (C) 1999-2019 by The D Language Foundation, All Rights Reserved written by Walter Bright
 lsb_release -a
No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 14.04.5 LTS Release: 14.04 Codename: trusty
 gcc --version
gcc (Ubuntu 4.9.4-2ubuntu1~14.04.1) 4.9.4 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
When I rewrote rdmd I read that some OS's don't support more than one argument on the shebang line, so I added support for "Source Compiler Directives". //!version test import std.stdio; void main() { writeln("Hello, world with automated script running!"); } If you use rdmd quite a bit, you might want to consider switching to rund: https://github.com/dragon-lang/rund It runs about twice as fast because it only needs to run the compiler once instead of twice like rdmd does. I also fixed a fair number of bugs with rdmd when I rewrote it. And if you find any issues with it, please let me know and I'll quickly make sure to get them fixed.
Apr 01 2019