How to set the working directory when running an executable in Eclipse CDT to be the same as the executable? - eclipse

I have several build dirs for different configurations (using an external build system from the CLI), so the executable name duplicates the desired cwd:
path/to/build1/executable
path/to/build1 (desired cwd)
path/to/build2/executable
path/to/build2 (desired cwd)
Is there a more convenient way to run the executable from the directory containing it, without typing the path twice?
The most likely solution would be with a variable like ${workspace_loc} under "Arguments -> Working directory", but I could not find a suitable variable.
Tested on Eclipse 4.6.3.

If you use managed build you can get away with specifying config_name appended to workspace_loc, i.e. if you project is called "test" this should work (tested on linux)
${workspace_loc:test}/${config_name:test}
My app prints
Current working dir: /home/elaskavaia/workspace/test/Debug

Related

How to eliminate RubyMine false "No such file to load" errors

I've recently installed RubyMine on a second machine and cloned a GitHub repository there.
My application runs exactly the same as on the first machine, but the RM code inspection result is radically different: I get dozens of "No such file to load" errors.
This even though the application runs fine both from the command line and from RM.
In dialog Run/Debug Configurations, I have specified load paths (-I. -I..) in the Ruby arguments.
Does the code inspection not honor the configuration? Or perhaps it's using a different configuration?
A bit late, but you may need to mark the directories that are load path roots in your app within the Rubymine tree - right click and do "Mark Directory As/Load Path Root".
For me the other solutions did not work. However, the problem was that RubyMine detected the wrong ruby version - while rvm for the project was ruby 2.4.1, in RubyMine it defaulted to the last version it had (2.4.2). So going to RubyMine > Preferences > Ruby SDK & Gems and changing the version for the project to the correct one solved it.
If you use the "Mark Directory As/Load Path Root" action, this will apply for IDE autocompletion only. It will not be propagated onto the interpreter (as it would be in PyCharm with Python).
You have to either keep using the -I switch, or configure $LOAD_PATH in your code, or (preferably) set up a Gem project with bundler support. You can then configure the path in a gemspec file. See https://www.jetbrains.com/help/ruby/creating-gem-project.html.
Sources:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206741945-Load-Path-not-working-at-all-
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206727915-Building-RubyGems-lib-in-load-path-
You can try changing Project Path Mappings and set relative Local Path and Remote Path to get it to work.

Run node-webkit project in Netbeans 7.4

I am trying to configure Netbeans IDE 7.4 for node-webkit development.
It is excellent IDE but I want to run my projects with F6 button. To do this I added NW.EXE as additional browser (executable is located outside project folder).
After this I have a problem with execution arguments. NW.EXE expects a folder path to be specified as an argument, but I cannot leave empty field of Start File in project settings and the Project URL has to start with either http:// or file:// while Node-webkit needs a path like C:/path_to_app
Does any method exist to deal with this feature?
In short, you can work this around by creating a batch program and let it strip the file name down to the path name part, to be fed to nw.exe, as it requires.
Unfortunately, as you said, we don't have full control over the way the main file of the project is passed to the browser, hence some further actions (in addition to the creation of the batch file) are needed.
This is how I got it working after a bit of struggle:
added nw.exe to the system %PATH% variable (optional, just for ease of access)
created nw.bat in the same folder as nw.exe, and filled it with this content:
#echo %1
start nw.exe %~d1%~p1
The first line of this batch file is just to inspect the actual parameter that is getting passed to the batch file.
The second line uses start to invoke nw.exe without having to wait for its return (you may need to specify the full path to nw.exe, if you didn't add it to the system %PATH% variable).
The second line also passes to nw.exe the drive part of the parameter (extracted from %1 by %~d1) concatenating it to the path of the parameter (extracted from %1 by %~p1).
For instance, my last run from within NetBeans gave this output:
D:\node\test\index.html
D:\node\test>start nw.exe D:\node\test\
Then I needed something to tie the NetBeans run button to an arbitrary executable, and luckily I found a perfect fit.
So here is how I went on:
installed the Node.js Projects plugin from Timboudreau Update Center
went to Options > Miscellaneous > Node.js and set the Node.js Binary field to point to my nw.bat file
In my project, I've also taken care to put package.json in the same folder of index.html (being that that's the main file of my package, and that's what will be fed to the batch file).
Now pressing F6 on my NetBeans installation happily runs my node-webkit project without any further ado :-)

how to setup grunt in webstorm on windows

I am Using Webstorm (PHPStorm) on Windows 7. On the actual project we are using grunt to concatenate javascript and css and also for several other build processes.
I tried to setup the grunt command as an external run command in Webstorm. The settings i tried for that are:
Name: grunt
Parameters: none
WorkingDirectory: $ProjectFileDir$
So now when I am trying to start my external run command in Webstorm, I always get the error
> grunt
Cannot run program "grunt" (in directory "C:\Users\jawidmer\workspaces\projectname"): CreateProcess error=2, The system cannot find the file specified
When I open my command line tool and navigate to the project folder, I can start grunt without any problems.
I already searched in google and tried all kinds of different combinations of settings but non of them worked..
Do you have any ideas, what I have to change to be able to start grunt from external run commands in Webstorm?
Thanks
Jan
By your description, I assume that the same way I configured it in my WebStorm installation should work just fine for you too:
I hope it helps.
UPDATE
It seems that if you add > %TEMP%\grunt & type %TEMP%\grunt & del %TEMP%\grunt to Parameters (like shown in the updated image), the build errors will be shown.
If you need to configure a task (for example grunt watch), the Parameters field must be the following:
watch > %TEMP%\grunt & type %TEMP%\grunt & del %TEMP%\grunt
Tip taken from here
Maybe this variant will be useful for somebody:
Settings -> External Tools
With this tool I can right-click folder in project and in context menu select grunt -> build
As I had problems with the path of node and grunt in linux. I've decide to add the following in Settings->External Tools, I guess in windows can be done in the same way (PHPstorm 7, in the same dialog as the prior answers):
Name: grunt Group: Node
Program: /opt/nodes/current/bin/node (my path to node files)
Parameters: /my/directory/node_modules/grunt-cli/bin/grunt watch (my path to grunt-cli binary and the parameter to the task of grunt)
Working directory: /home/user/project/ (my path to Gruntfile.js)

Eclipse Erlide how to choose default current directory

I have installed Erlide in Eclipse, and trying to create an application. The Erlang project is named demo. It contains three folders - ebin, include and src. The demo.erl file is in src, for simply printing Hello World.
To run it in Eclipse shell, I choose Run from the top menu, and click Run as Erlang Application. Then a console opens in the sidebar. There I type c(demo) and press CTRL-Enter. Then I get an error message like demo.erl:none: no such file or directory.
Then I do pwd(), and it shows C:/Users/myName/Desktop/eclipse-jee-juno-SR1-win32-x86_64/eclipse even though the Erlang project is in workspace C:/Users/myName/Desktop/workspace/Erlang. Is there any way make Erlide run all Erlang applications from their directory directly?
If you have set Project -> Build Automatically in Eclipse to true, you don't need to type c(demo). explicitly to compile the demo module, it's done automatically when you save your file. But if you have not set it, you'll get exception error: undefined function if you try to use some of the functions in the module for example.
To make the c(demo) command work properly and find your .erl files, there are several ways to set the current working directory:
Use Run -> Run Configuration -> Erlang Application -> Runtimes -> Working directory -> enter the full path to the /src folder of your project (without quotes).
Then hit Apply and restart Eclipse (File -> Restart). If you try to Run the project without first restarting the IDE, your changes will not take effect i.e. the pwd(). command will still be returning the old working directory path.
You can set the working directory in the erlide console with the command c:cd(the/full/path/to/your/src/folder)., before the call to c(demo). The path should be put in quotes.
You can also set the working directory in the .erlang file by typing there the same command c:cd(the/full/path/to/your/src/folder). (the path again should be put in quotes). The file must be placed in you user directory, for Windows this would be C:/Documents and Settings/YourUsername. It's the same directory were also .erlang.cookie and erlide-debug.txt are placed. Windows Explorer will not allow you to create a file named .erlang, so you have to use the command copy NUL .erlang in Command Prompt (cmd.exe) for this. Then you can edit it with any txt redactor. Don't forget to restart Eclipse again after it.
Also note the following:
You can use only / and not \ in the path (even in Windows).
If you have entered a wrong path (with \ or to a non existing directory), it will be ignored and the working directory will not be changed at all.
After changing the working directory to your/src folder, your beam files will start to appear there too instead of the /ebin folder.
If you set a different path in both .erlang file and Run -> Run Configuration -> Erlang Application -> Runtimes -> Working directory, pwd(). will return the path in .erlang file.
You don't need to run c(demo). The beam code is loaded and reloaded automatically, whenever the source is changed and saved.
If you still need to set a working directory, go to run->run configuration and you can edit the configuration.
/Vlad

NUnit read file from source Bin

I've a class library in visual studio with a method that just checks if specified file exists or not. If I pass just file name (without full path) of some text file which exists in the bin directory, it works fine by identifying its existence.
Hence File.Exists("myfile.txt") works if myfile.txt is in bin directory.
But when I load a test case from NUnit GUI which executes this method, it fails to read the file. Likely because bin directory executing NUnit is different than original bin where dll and myfile.txt reside. How can I tackle this in my NUnit without resorting to hardcoded full path?
In your tests pass a relative path to the method of the class under test. This avoids resorting to a hard coded full path and as long as your test project is always in the same location relative to your source project it'll work.
e.g. if you have your source set up like this:
\Solution\src\Project\bin\debug\myFile.txt
\Solution\test\TestProject\bin\debug\TestAssembly.dll
The relative path will be #"..\..\..\..\Project\bin\debug\myfile.txt"
Update
I'm not quite sure why your tests are running from a temporary folder. I either use a test runner such as Resharper or set up my test project as follows:
Open the project properties for the project containing your tests.
Go to the Debug tab and set the following values:
Start external program: Enter the location of nunit.exe, e.g. on my PC it's installed to C:\Program Files\NUnit 2.5.5\bin\net-2.0\nunit.exe.
Command line arguments: Enter the name of your assembly containing your tests followed by the run argument, e.g. TestProject.dll /run.
Set the project containing your tests as the StartUp Project.
Hit F5.
This way your tests will always run from bin\debug (depending on how your build is configured), so you can rely on projects always being in the same relative location.