www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - dmd error in wsl2

reply bharathyes <bharathyes.in gmail.com> writes:
I am facing an issue compiling an hello world program using dmd 
v2.096.1 running on WSL2 debian.

I wrote the basic code:

```d
void main() {
     import std.studio;
     string name ;
     write("What is your name?");
     readf("%s\n", &name);
     writeln("Hellow ", name);
}
```

This throws the following no compiling:

```
$ dmd hellow.d                                                
21:16:13
hellow.d(2): Error: module `studio` is in file 'std/studio.d' 
which cannot be read
import path[0] = /usr/include/dmd/phobos
import path[1] = /usr/include/dmd/druntime/import
```

---

What is the process to follow here? Is this an permission issue ( 
since it says cannot be read ) or do I need to add any import 
statement for this to work?

PS: Not to get off-topic but is using WSL to learn DLang a bad 
idea to begin with? I am just getting used to WSL + VS Code and 
trying to stick to it when possible. `cmd` & `powershell` is just 
a headache for me to use.
May 25
next sibling parent reply MoonlightSentinel <moonlightsentinel disroot.org> writes:
On Tuesday, 25 May 2021 at 15:54:31 UTC, bharathyes wrote:
 I wrote the basic code:
You have a typo in your code, `std.studio` instead of `std.stdio`.
May 25
parent bharathyes <bharathyes.in gmail.com> writes:
On Tuesday, 25 May 2021 at 15:59:21 UTC, MoonlightSentinel wrote:
 On Tuesday, 25 May 2021 at 15:54:31 UTC, bharathyes wrote:
 I wrote the basic code:
You have a typo in your code, `std.studio` instead of `std.stdio`.
Thanks. I spent more than half hour searching for this error but never figured to check the spelling.
May 25
prev sibling parent reply mw <mingwu gmail.com> writes:
On Tuesday, 25 May 2021 at 15:54:31 UTC, bharathyes wrote:
 I am facing an issue compiling an hello world program using dmd 
 v2.096.1 running on WSL2 debian.

 I wrote the basic code:

 ```d
 void main() {
     import std.studio;
     string name ;
     write("What is your name?");
     readf("%s\n", &name);
     writeln("Hellow ", name);
 }
 ```

 This throws the following no compiling:

 ```
 $ dmd hellow.d                                                
 21:16:13
 hellow.d(2): Error: module `studio` is in file 'std/studio.d' 
 which cannot be read
 import path[0] = /usr/include/dmd/phobos
 import path[1] = /usr/include/dmd/druntime/import
 ```

 ---

 What is the process to follow here? Is this an permission issue 
 ( since it says cannot be read ) or do I need to add any import 
 statement for this to work?

 PS: Not to get off-topic but is using WSL to learn DLang a bad 
 idea to begin with? I am just getting used to WSL + VS Code and 
 trying to stick to it when possible. `cmd` & `powershell` is 
 just a headache for me to use.
I think `powershell` is a Windows thing, which caused the path finding trouble. Your better in a Linux shell e.g. `wsl -u root`. Can you directly use a console from debian? e.g start by clicking the app with the icon of Ubuntu.
May 25
parent bharathyes <bharathyes.in gmail.com> writes:
On Tuesday, 25 May 2021 at 16:15:55 UTC, mw wrote:

 I think `powershell` is a Windows thing, which caused the path 
 finding trouble. Your better in a Linux shell e.g. `wsl -u 
 root`.

 Can you directly use a console from debian? e.g start by 
 clicking the app with the icon of Ubuntu.
I am using debian directly ( through the Terminal Preview app or within VS Code ). The recommended install script had me "activate" to use dmd and since that concept was out of my understanding, I re-installed dmd using `apt`. But it kept throwing that error and I just couldn't find a way to import paths. Turns out it was a typo as pointed above and now it just compiles and runs successfully.
May 25