erlang / erlide_eclipse

Eclipse IDE for Erlang
http://erlide.org
202 stars 70 forks source link

doesnt write on file #318

Closed tschomacker closed 6 years ago

tschomacker commented 6 years ago

I am unable to write on files via Erlide. The following function wrote flawless on the file with Erlang OTP, but in erlide it doesnt do any thing:

printG(Graph,Filename) -> EdgeList = getEdges(Graph), IsDirected=util:getglobalvar(yndirected), NewNewFilename=atom_to_list(Filename)++".dot", if IsDirected==directed -> %% directed graph file:write_file(NewNewFilename,"digraph { " ++ printDEL(EdgeList),[write]); true -> %% undirected graph file:write_file(NewNewFilename,"graph { " ++ printUEL(EdgeList),[write]) end, io:fwrite("Graph written to " ++ NewNewFilename ++ "\n").

%% Prints edgelist of an directed graph to a .dot file printDEL([L, R, Weight | Rest]) -> toString(L) ++ " -> " ++ toString(R) ++ " [ label =\"" ++ util:to_String(Weight) ++ "\" ]" ++"\n" ++ printDEL(Rest); printDEL([]) -> "}".

vladdu commented 6 years ago

That is weird. Is just the writing to that doesn't work? That is, is the "Graph witten to..." message being printed in the console? BTW, what version of erlide?

vladdu commented 6 years ago

It works for me. What is your cwd() in the Erlang shell? I think the problem is that the default value is the eclipse installation directory, instead of the project's directory (which would be the expected value). Can you please confirm that the files are created in cwd()?

vladdu commented 6 years ago

Actually, the reason the cwd() is in the workspace root is that one can start an Erlang runtime on multiple Erlang projects, and then there is no other common place.

You should not rely on the cwd() being in a specific place, it will depend on where Erlang was started from. I would have the file name be a full path, so that I can specify exactly where the file is created.

Please confirm that your files are in the eclipse workspace directory.

tschomacker commented 6 years ago

e. g. "Graph written to file.dot" is the ouput but there is no file.dot wheter in src or in ebin. My source files are in src and the beams are in ebin. cwd() results in "** exception error: undefined shell command cwd/0". I have Eclipse Oxygen and Erlide 0.52.1 Thanks for your fast reply and I apologize for replying so late.

vladdu commented 6 years ago

I'm sorry, it shoulf be pwd().

tschomacker commented 6 years ago

pwd() resulted in "C:/Windows/system32", I checked there is also no file.dot (probably lack of rigths). Is there a way to change the working directory permanently? Or even better: That the project directory is automatically the working directory?

vladdu commented 6 years ago

You can do cd("dir"). to see.

Go to Run->Run configurations and find the one for your Erlang project. On the runtime tab there is a "working directory" field. You can set a different value there -- but I notice now that the value seems to be ignored. I will check that.

tschomacker commented 6 years ago

I checked for the value, it is my eclipse workspace. But there is also not a file.dot file. I changed it to another folder but still no file.dot file. It really appears to be ignored.

vladdu commented 6 years ago

I will fix that.

Does it work if you cd() into another directory where you can write?

tschomacker commented 6 years ago

Yes, that worked.

vladdu commented 6 years ago

Ok, then the working directory being ignored is the only problem. I will fix it.

vladdu commented 6 years ago

The fix will be available shortly in a nightly build. You need to go to "run->run configurations" and remove the existing erlang configuration(s) so that they can be recreated.