Eclipse Erlide how to choose default current directory - eclipse

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

Related

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

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

Netbeans, phpdocumentor, and custom phpdoc.dist.xml by project

I am using Netbeans 8.0.2 and phpdocumentor 2.8.2 on a windows 7 platform.
I would like to use custom phpdoc.dist.xml config files by project so I can specify framework directories and etc. to exclude from the generated doc. I also want to keep my Netbeans PHPDOC plugin config as generic as possible, without specific output directories, ignore options, config path parameters, etc., so on, so that that the config will apply to all my projects.
The phpdoc.dist.xml file works great. The doc generated is exactly what I want.
The problem or feature, and it seems to be a phpdocumentor one as it also applies from plain command line, is that the phpdoc.bat command (without a specific config parm) has to be run from the same root directory as the phpdoc.dist.xml file, or it ignores it. No problem if I'm using command line as I can change into that directory first, but I would like to use Netbeans. I have searched on this extensively and cannot find an answer.
I considered whether to modify the phpdocumentor files to insert cd /D path/to/myproject/dir to change the directory using some Netbeans variable to represent myproject/dir, but I could not find the right place in the code or the variable to use. Plus, then I'm supporting a custom mod to phpdocumentor.
I did find these directions for a PHPStorm setup, where the author specified a PHPStorm variable for the --config command line option to point to his custom phpdoc.dist.xml.
--config="$ProjectFileDir$/phpdoc.dist.xml"
If I could do the same in Netbeans like maybe "${BASE_DIR}/phpdoc.dist.xml" it would be great, but so far I haven't hit on anything Netbeans will recognize/pay attention to in the PhpDoc script: box.
I have also tried writing a wrapper .bat file to capture my own command line variable %1 and do the directory change to that before calling phpdoc.bat, but Netbeans throws and error and says that's not a valid .bat file. I cannot find any phpdocumentor parameter to configure by specific Netbeans project but the output directory. And I would prefer not to be defining a bunch of projects on subdirectories in Netbeans, just to address phpdocumentor.
Now I am out of ideas. Can anyone point me to a solution?

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 :-)

OpenERP 7 development environment: web module not found

I setup an Ubuntu environment and used bzr to get the 3 trunks: addons, server, web
Everything works and the server starts fine.
I then loaded the project in Eclipse and tried to run openerp-server. I got this error (module web: module not found). I then copied the entries (addons_path) in the openerp-server.conf from /etc/ to the conf file in server/install folder. I also created a copy of this file and pasted in server folder, in the hopes that eclipse would pick it up.
But I am still getting the same error. Three questions please:
Which conf file should I add this path for eclipse to use? Where does this file reside?
If I must use a command line switch to specify the web/addons path then how do I do that in eclipse?
There used to be a file with a lot of different variable such as pg_path, rpc, etc. Is that file still around? Maybe that is where I need to make this entry?
Thanks
I had to add a "-c /etc/openerp-server.conf" argument. Right click on the openerp-server file, launch the properties window, select Run/Debug Settings, select the only launch configuration available, edit, select the arguments tab.
I added them manually to eclipse run configurations > arguments.
e.g.
--db_host = {host}
--db_port = {port}
--db_user = {user}
--db_password = {password}
--addons = ../addons,../server/addons

PyDev Unit Test Set Run Directory

I have a PyDev unit test module that lives at the path:
$(PYDEV_PROJECT_ROOT)/tests/my_unit_test.py
I am attempting to use Eclipse PyDev's unit testing facilities. My unit test must read a configuration file like so:
(foo,bar,baz) = myModule.readOptimizationConfig("tests/optimization_config_file.cfg")
However, this will not work because PyDev goes into the 'tests' directory before running, and so specifying 'tests/' in the path given to readOptimizationConfig makes it attempt to load
$(PYDEV_PROJECT_ROOT)/tests/tests/optimization_config_file.cfg
However, I also need to run these tests using nosetests from the command lin.
This is because, in order to run ALL the tests for my project, rather than the option for running them in a particular file that is provided by default, the easiest solution was to just use the 'nosetests' command, rather than messing with Eclipse launch configurations. However, nosetests needs to be be run from the $(PYDEV_PROJECT_ROOT) root directory, so it needs the 'tests/' specified in the path.
Is there a way to force eclipse to run the unit tests from the project root directory, so that the paths that I pass to readOptimizationConfig will work for both methods?
It is possible to do this in PyDev, but you have to do it per every launch configuration so it's a bit boring.
Anyway, you first try to run as your script containing the unit-test (as you normally would - e.g. the dropdown menu next to the green "Run" arrow button then Run as... - Python unit-test). This launch will fail because of your missing cfg file. Now go to Run configurations (Run dropdown - Run configurations), open the Arguments tab and in the bottom under Working directory enter the path you want (or browse for it using the Workspace... button). For example if you want to run from project root and your project is called awesome-project, you would write:
${workspace_loc:awesome-project}
Now you should have a valid launch configuration that you can use from both the Run and Debug menus. I sometimes rename these configurations to something noticeable right away e.g. "awesome-project TEST".