digitalmars.D.ide - Issues with workspace-d and code-d on Linux
- Igor (51/51) Jul 25 2018 After reading a few posts of users complaining about first time
- Laurent =?UTF-8?B?VHLDqWd1aWVy?= (8/12) Jul 26 2018 This extension enables debugging with GDB/LLDB :
- Igor (65/75) Jul 27 2018 Thanks Laurent. It is working now. For future reference I will
After reading a few posts of users complaining about first time user experience with DLang on Windows in the past two years I now come to write about my issues on Linux. On Windows I would download 4 installers: Visual Studio Community Edition (and make sure to check C++ and Windows SDKs in it) DMD installer LDC installer VisualD installer I would install those 4 things in order and I would open VS where I could create new DLang project, place a breakpoint, press F5 to debug it, with a few clicks switch from using DMD to LDC and I would have autocomplete. That is all I wanted on my new Kubuntu Linux but I am starting to give up. I installed VSCode and using an install script the latest LDC (1.10.0) and DMD (2.081.1). I got a message how I need to source appropriate activate file to add the compiler I want to the PATH. Ok I understand that part. Then I lookup the code-d extension in VSCode and in the description it says in needs some dependencies and from the description I am not sure if it will install everything it needs automatically or I need to install it myself. To be sure I decided to install it myself. I followed the code-d wiki, cloned workspace-d and run its install.sh. At installing dcd-client it stops with the exception "dcd-client: File or directory does not exist". So I open the script and then installer's app.d and see that after building dcd-client and dcd-server it expects to find them in the project root folder so I change the source so the paths are "bin/dcd-client" and "bin/dcd-server". I run it again and this time it built those but crashed at building dfmt. It turned out its make script is passing -inline and -version=Something to ldc2 and it complains how there is no inline flag and that version flag doesn't expect a value. I remove the inline flag and change -version to -d-version, build just dfmt again and manually copy the bin where workspace-d installer would put it. After this I setup the system so LDC and workspace-d/bin folders are always in the PATH since I don't expect code-d to source some activate file somewhere. Finally I can install code-d, or so I think. I install it and do Ctrl-Shift-P, "code-d: Create new project", "Empty console project" and I notice in the VSCode output that code-d is installing DCD. So it didn't find the one I setup with so much work. Also once the new project was loaded among all kinds of messages I also got: Could not resolve location of module 'std/stdio' And as I suspected typing "writ", Ctrl+Space did not autocomplete it. On top of that I am new to VSCode so I have no idea how it is supposed to know how to build and run my project. All I can tell is that pressing F5 doesn't work. And so here I am, hoping that someone can explain how to set everything up so I get Windows like experience while working with VSCode on Linux (or some other editor).
Jul 25 2018
On Wednesday, 25 July 2018 at 20:03:49 UTC, Igor wrote:[...] And so here I am, hoping that someone can explain how to set everything up so I get Windows like experience while working with VSCode on Linux (or some other editor).This extension enables debugging with GDB/LLDB : https://marketplace.visualstudio.com/items?itemName=webfreak.debug. Since you installed DMD and LDC using the install.sh script, you will need to manually set the `d.stdlibPath` value in VSCode's settings to an array of paths to druntime and phobos (you should find them somewhere in ~/dlang if you used the default install place). This way code-d should have proper completion.
Jul 26 2018
On Thursday, 26 July 2018 at 09:42:13 UTC, Laurent Tréguier wrote:On Wednesday, 25 July 2018 at 20:03:49 UTC, Igor wrote:Thanks Laurent. It is working now. For future reference I will write all steps here. This guide assumes DMD is installed using the install script: curl -fsS https://dlang.org/install.sh | bash -s dmd ~/dlang/install.sh install dmd ~/dlang/install.sh install ldc If you want to permanently set PATH and other needed variables you need to copy them from activate script of one of installed compilers into your .profile file. If you are on KDE then it should go in ~/.config/plasma-workspace/env/ldc.sh. This is how my ldc.sh looks like since I have KDE and I want ldc compiler by default: if [ -d "$HOME/dlang/ldc-1.10.0" ] ; then PATH="$HOME/dlang/ldc-1.10.0/bin${PATH:+:}${PATH:-}" export PATH="$HOME/git/workspace-d/bin${PATH:+:}${PATH:-}" export LIBRARY_PATH="$HOME/dlang/ldc-1.10.0/lib${LIBRARY_PATH:+:}${LIBRARY_PATH:-}" export LD_LIBRARY_PATH="$HOME/dlang/ldc-1.10.0/lib${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH:-}" export DMD=ldmd2 export DC=ldc2 fi After that install VSCode if it is not already installed. Open it and go to Extensions tab (last icon on the left). Search for "webfreak". You will see "D Language utility extension pack" which contains all you need for the DLang development. In the description you can see what individual plugins it installs and what they do so if you choose you can only install some of them. "D Programming Language (code-d)" is required for autocomplete and "Native Debug" for debugging. Once you install that and reload VSCode go to File-Preferences-Settings (Ctrl+,). In the right part of the window, under User Settings you will see some dlang settings are already added. Bellow them I also added this: "d.dmdPath": "ldmd2", "d.stdlibPath": [ "/home/igors/dlang/dmd-2.081.1/druntime/import", "/home/igors/dlang/dmd-2.081.1/phobos" ], First line is needed because I want to use LDC compiler. After that you can open View-Command Pallete (Ctrl+Shift+P) and type code-d and see all kind of commands related to it and one of them should be "Create new project". This will init your project with a single d code file and basic dub configuration for building it. If at that point you press F5 you will be offered to add a GDB (or LLDB if you have clang installed) configuration for debugging. Once you do that you will get a launch.json file under .vscode dir in your project and there you should add this line: "preLaunchTask": "buildAndRun", After that you should select Tasks-Configure Tasks and in the drop down select dub: Run option. That will create a tasks.json file for building and running your project. You should add this line so launch.json can reference it: "identifier": "buildAndRun", If at this point you press F5 to debug your program it will be built but debugger will probably report an error how it couldn't find what to debug. You need to see where you program was build (by default in the root of your project) and then put its name in launch.json under target property. For example my project is called dtest so I set it up like this: "target": "./dtest", At this point it should be clear what goes where and how it works so you can now edit your json files and configure them to your liking.[...] And so here I am, hoping that someone can explain how to set everything up so I get Windows like experience while working with VSCode on Linux (or some other editor).This extension enables debugging with GDB/LLDB : https://marketplace.visualstudio.com/items?itemName=webfreak.debug. Since you installed DMD and LDC using the install.sh script, you will need to manually set the `d.stdlibPath` value in VSCode's settings...
Jul 27 2018