These are chat archives for ceylon/ceylon-ide-eclipse

18th
Oct 2016
Gavin King
@gavinking
Oct 18 2016 10:19
oh great, I started getting this in Eclipse @davidfestal:
The Ceylon Java backend compilation failed
  with a throwable : com.redhat.ceylon.langtools.tools.javac.code.Symbol$CompletionFailure: class file for com.redhat.ceylon.common.NonNull not found
not in intellij
Stéphane Épardaud
@FroMage
Oct 18 2016 10:25
yes, related to @tombentley 's recent work probably
Gavin King
@gavinking
Oct 18 2016 10:25
sure
David Festal
@davidfestal
Oct 18 2016 11:27
@gavinking please open an issue and assign it to me
Gavin King
@gavinking
Oct 18 2016 11:27
already done
David Festal
@davidfestal
Oct 18 2016 11:27
I'll fix all those one after the other.
I'm still on the functional interface stufff for now
(I should be able to test soon, but there might be some problems since the JDT functions for SAMs expect a Java compilation unit scope :-( )
then the NPM
then this one
Gavin King
@gavinking
Oct 18 2016 11:29
ok
David Festal
@davidfestal
Oct 18 2016 16:08
@gavinking I've been able to run the NPM example without any problem. So I'm debugging it to undertand what might be the difference with you
Gavin King
@gavinking
Oct 18 2016 16:11
well it could surely be mac-specific
something to do with how brew lays out the installation
but, again: it works on the command line
David Festal
@davidfestal
Oct 18 2016 16:12
I'm nearly at the point when it should use node
Gavin King
@gavinking
Oct 18 2016 16:12
which is wierd
David Festal
@davidfestal
Oct 18 2016 16:12
this will make things clearI hope
Gavin King
@gavinking
Oct 18 2016 16:13
it’s still happening to me in both Eclipse and IntelliJ FTR
David Festal
@davidfestal
Oct 18 2016 16:14
yes, I've implemented it in common :-)
so that's not surprising !
Gavin King
@gavinking
Oct 18 2016 16:16
heh ok
John Vasileff
@jvasileff
Oct 18 2016 16:17
how is node being found? For me, I think it’s with some ancient thing I added launchctl setenv NODE_EXE ~/opt/node/bin/node, which wouldn’t cover npm.
Gavin King
@gavinking
Oct 18 2016 16:17
note that brew buts symlinks to stuff
@jvasileff on the commandline, it finds npm
and node and npm are in the same spot
John Vasileff
@jvasileff
Oct 18 2016 16:17
but does Eclipse have the same PATH?
Gavin King
@gavinking
Oct 18 2016 16:17
Gavins-MacBook-Pro-2:ceylon gavin$ which node
/usr/local/bin/node
Gavins-MacBook-Pro-2:ceylon gavin$ which npm
/usr/local/bin/npm
but they’re symlinks, mind
David Festal
@davidfestal
Oct 18 2016 16:18
it might also be the NODE_PATH (that tells where the npm modules can be found)
That's what I'm looking into
Gavin King
@gavinking
Oct 18 2016 16:18
ok
Gavins-MacBook-Pro-2:ceylon gavin$ echo $NODE_PATH

Gavins-MacBook-Pro-2:ceylon gavin$
damn that did not come out
apparently NODE_PATH is empty on the CLI
David Festal
@davidfestal
Oct 18 2016 16:19
echodavid@travail-david-gnome:~/git/ceylon-ide-eclipse$ echo $NODE_PATH
/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
don't know if it makes a difference
Gavin King
@gavinking
Oct 18 2016 16:19
could do, surely
David Festal
@davidfestal
Oct 18 2016 16:19
let finish debugging
Gavin King
@gavinking
Oct 18 2016 16:20
perhaps it checks NODE_PATH and finding nothing, blows up
David Festal
@davidfestal
Oct 18 2016 16:20
but why would it work on the CLI then ?
Tako Schotanus
@quintesse
Oct 18 2016 16:20
NODE_PATH is not necessary AFAIK
Gavin King
@gavinking
Oct 18 2016 16:20
dunno
David Festal
@davidfestal
Oct 18 2016 16:20
it's the same repo manager that is used
and it is not the same as on the CLI
David Festal
@davidfestal
Oct 18 2016 16:24
haha, interesting :-)
John Vasileff
@jvasileff
Oct 18 2016 16:24
just has /usr/bin and three others
but it does have my NODE_EXE var mentioned above
David Festal
@davidfestal
Oct 18 2016 16:29
This code might be interesting:
    private CmrRepository createNpmRepository(String token, Logger log, boolean offline) {
        File local = new File("node_modules");

        String nodePath = token.substring(4);
        if (nodePath.isEmpty()) {
            nodePath = System.getenv("NODE_PATH");
            if (nodePath == null || nodePath.isEmpty()) {
                nodePath = local.getAbsolutePath();
            }
        }

        File[] roots = FileUtil.pathToFileArray(nodePath);

        // If we have a single root to look up NPM modules we assume
        // we can use it for output as well. If we have several we
        // take the output to be "node_modules"
        // TODO: is this heuristic correct/useful?
        File out;
        if (roots.length > 1) {
            out = local;
        } else {
            out = roots[0];
        }

        NpmContentStore cs = new NpmContentStore(roots, out, log, offline);
        return new NpmRepository(cs.createRoot());
    }
Gavin King
@gavinking
Oct 18 2016 16:31
@jvasileff dunno, according to that I have no PATH :)
nodePath = System.getenv("NODE_PATH");
            if (nodePath == null || nodePath.isEmpty()) {
                nodePath = local.getAbsolutePath();
            }
John Vasileff
@jvasileff
Oct 18 2016 16:31
what do you have? Anything that would indicate where node is?
Gavin King
@gavinking
Oct 18 2016 16:31
so wtf is local.getAbsolutePath()? could it be different in Eclipse compared to CLI?
John Vasileff
@jvasileff
Oct 18 2016 16:32
the CLI evaluates .bash_profile and .bashrc first. And I guess Eclipse doesn’t when launched from the gui
Gavin King
@gavinking
Oct 18 2016 16:32
@jvasileff not that I can see
I wonder if it would work if I set NODE_PATH
David Festal
@davidfestal
Oct 18 2016 16:32
wait, I think your problem is not finding the node executable
Gavin King
@gavinking
Oct 18 2016 16:32
but no clue what to set it to
no, it finds node just fine
it’s npm it can’t find
David Festal
@davidfestal
Oct 18 2016 16:33
the problem is that NODE_PATH should return the list of places npm modules can be found
usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript on my machine
Tako Schotanus
@quintesse
Oct 18 2016 16:34
no it doesn't !
it's the place where the modules are installed
ok, heh
I thought I read "where npm can be found" ^^
David Festal
@davidfestal
Oct 18 2016 16:34
yes, OK, I didn't explain it correctly
where the NPM modules are searched for
so it you don't have that correct in Eclipse
Tako Schotanus
@quintesse
Oct 18 2016 16:36
but that shouldn't matter because npm and node just work fine with a local "node_modules" folder
David Festal
@davidfestal
Oct 18 2016 16:36
the npm modules can be downloaded by npm, but they won't be seen by the NPM support afaik
Gavin King
@gavinking
Oct 18 2016 16:36
hrm
so I found something
apparently, on my machine
Tako Schotanus
@quintesse
Oct 18 2016 16:37
They should. In both cases it should just download it to and read it from the local node_modules
Gavin King
@gavinking
Oct 18 2016 16:37
npm install just puts modules in cwd
well in node_modules subdir of cwd
Enrique Zamudio
@chochos
Oct 18 2016 16:37
yes
Gavin King
@gavinking
Oct 18 2016 16:37
isn’t that weird?
Tako Schotanus
@quintesse
Oct 18 2016 16:37
@gavinking yes, that's its default behaviour
Everything gets its own copy of everything, no central repo (at least not by default AFAIK)
Gavin King
@gavinking
Oct 18 2016 16:38
so what is cwd in Eclipse?
Tako Schotanus
@quintesse
Oct 18 2016 16:38
I think it's the root of your project
Gavin King
@gavinking
Oct 18 2016 16:38
what if it’s not the same as the project root?
John Vasileff
@jvasileff
Oct 18 2016 16:38
what’s a good test import to try? (i.e., what to use for some-module import npm:"some-module" "1.2.3”;)
Enrique Zamudio
@chochos
Oct 18 2016 16:38
uuid or left-pad
Gavin King
@gavinking
Oct 18 2016 16:39
import npm:”left-pad" "1.1.3;
John Vasileff
@jvasileff
Oct 18 2016 16:39
thx
Enrique Zamudio
@chochos
Oct 18 2016 16:39
fucking left pad ended up being the most popular module
Gavin King
@gavinking
Oct 18 2016 16:39
haha
the irony
i love it
@davidfestal check what is the cwd in Eclipse
it’s supposed to be the project root, but if it’s not, that could be a prob, it seems to me
David Festal
@davidfestal
Oct 18 2016 16:41
@gavinking the npm is downloaded in <project root>/node_modules regardless what the current direcory of eclipse is
according to this code:
John Vasileff
@jvasileff
Oct 18 2016 16:41
ok, so same:
Error running NPM installer (make sure npm is installed and available in your PATH)
David Festal
@davidfestal
Oct 18 2016 16:41
            ProcessBuilder pb = new ProcessBuilder()
                    .command("npm", "install", "-q", name + "@" + version)
                    .directory(out.getParentFile())
                    .inheritIO();
Gavin King
@gavinking
Oct 18 2016 16:41
@jvasileff you are on mac too, right?
John Vasileff
@jvasileff
Oct 18 2016 16:41
@davidfestal is anything other than PATH used to try to find npm?
@gavinking right
@davidfestal or do I have to try to set eclipse’s PATH?
David Festal
@davidfestal
Oct 18 2016 16:42
the current directory of the started npm command is set to the out
nothing is used tofind npm
it's just npm
John Vasileff
@jvasileff
Oct 18 2016 16:43
so PATH then I guess.
David Festal
@davidfestal
Oct 18 2016 16:43
so it depends on how the system manages the PATH from a process to a child process
Tako Schotanus
@quintesse
Oct 18 2016 16:43
So perhaps from within the IDE's path it can't find npm. We could perhaps add a System property to override that. Something the IDE can set so Ceylon can find the executable
Gavin King
@gavinking
Oct 18 2016 16:44
But it finds node!
John Vasileff
@jvasileff
Oct 18 2016 16:44
how???? Sure you don’t have NODE_EXE in eclipse?
David Festal
@davidfestal
Oct 18 2016 16:44
well, it does on linux, but it might depend on the system
Tako Schotanus
@quintesse
Oct 18 2016 16:44
Because form the CLI I think it's okay to require that npm has to be in the PATH, but I guess for the IDE it's not
Gavin King
@gavinking
Oct 18 2016 16:44
is it using a different strategy to find node?
David Festal
@davidfestal
Oct 18 2016 16:44
might be
John Vasileff
@jvasileff
Oct 18 2016 16:44
node is found by the JS run tool, I think
Gavin King
@gavinking
Oct 18 2016 16:45
that is code witten by @chochos
Tako Schotanus
@quintesse
Oct 18 2016 16:45
I think I made @chochos remove some hard-coded ways of finding npm, perhaps he didn't do the same for node ;)
Argh, exactly. That's really so not done
Enrique Zamudio
@chochos
Oct 18 2016 16:46
so it finds node but not npm?
Tako Schotanus
@quintesse
Oct 18 2016 16:46
So I'd rip out that code too and give the IDE some proper way of specifying where both nodeand npm can be found
John Vasileff
@jvasileff
Oct 18 2016 16:47
@gavinking one way, probably not the best, might be to edit /etc/paths to add npm’s location
should work.
Gavin King
@gavinking
Oct 18 2016 16:47
ok, so my node location is hardcoded in that list
John Vasileff
@jvasileff
Oct 18 2016 16:51
hm. that didn’t work. Shouldn’t need a reboot, but I’ll try
regardless, we need something better
David Festal
@davidfestal
Oct 18 2016 16:52
hey, in my case in fact the node_modulesfolder where modules are downloaded is the directory from which I start Eclipse
:-(
In the following code of the NpmRepositoryBuilder.createNpmRepository():
    private CmrRepository createNpmRepository(String token, Logger log, boolean offline) {
        File local = new File("node_modules");

.....
we should prefix the cwd setting of the repository manager IMO
at least when it is set
John Vasileff
@jvasileff
Oct 18 2016 16:55
it should be in the project root dir, no?
David Festal
@davidfestal
Oct 18 2016 16:56
yes, it would be if we do the change I've just mentioned
let me do it locally
Tako Schotanus
@quintesse
Oct 18 2016 16:57
@davidfestal don't push it , because I'm working on that as well ;)
David Festal
@davidfestal
Oct 18 2016 16:57
Ha, OK, I'll let you do it then. I have no need for that here, and can easily wait for your change :-)
Tako Schotanus
@quintesse
Oct 18 2016 16:58
:+1: :)
David Festal
@davidfestal
Oct 18 2016 16:58
let me come back to the tests of the functional interfaces on Eclipse + Android support
Tako Schotanus
@quintesse
Oct 18 2016 16:59
So it seems the run-js tool does have a way to override the location of the npm executable, but I don't like how it's defined so I'm changing it ;)
David Festal
@davidfestal
Oct 18 2016 17:00
how was it ?
perhaps we were using it in the IDE
Tako Schotanus
@quintesse
Oct 18 2016 17:00
Sorry, the node executable I mean
With the node.exe System property
David Festal
@davidfestal
Oct 18 2016 17:01
ah, yes, I think I remember
Tako Schotanus
@quintesse
Oct 18 2016 17:01
(Also the NODE_EXE environment var, but that I'm leaving the same because it's the official way)
John Vasileff
@jvasileff
Oct 18 2016 17:01
for setting Eclipse’s PATH, the best I’ve found: https://dev.eclipse.org/mhonarc/lists/photran/msg01967.html but its a pita
Tako Schotanus
@quintesse
Oct 18 2016 17:01
I'm now introducing ceylon.command.node and ceylon.command.npm to do the same
David Festal
@davidfestal
Oct 18 2016 17:02
OK, cool
John Vasileff
@jvasileff
Oct 18 2016 17:02
@quintesse env vars? I’ve been using launchctl setenv NODE_EXE ~/opt/node/bin/node
so just s/NODE_EXE/ceylon.command.node ?
Tako Schotanus
@quintesse
Oct 18 2016 17:03
No :)
Read again :point_up: October 18, 2016 7:01 PM
Leaving that as-is
John Vasileff
@jvasileff
Oct 18 2016 17:04
oh, so ceylon.command.node,npm are in .ceylon/config
Tako Schotanus
@quintesse
Oct 18 2016 17:05
No, they are just System properties, I don't want to fuck with path stuff in our config to be honest
For the CLI we'll just require that node and npm must be in your path, if you really want you can add -Dceylon.command.node to override that, but it's basically more of a "hidden" option so the IDE has a way to tell Ceylon where to look
John Vasileff
@jvasileff
Oct 18 2016 17:10
ok. So then I suppose macOS users would then set these in eclipse.ini if nec. and @davidfestal’s code should honor them.
David Festal
@davidfestal
Oct 18 2016 17:11
well, the code in runjs and NpmRepositoryBuilder (which is not my code ;-) ) should honour them
so that it should be taken in account automatically by eclipse
John Vasileff
@jvasileff
Oct 18 2016 17:16
@gavinking the steps in this link worked for me
Tako Schotanus
@quintesse
Oct 18 2016 17:20
Anyone with a Mac can explain to me why we're checking System.getenv("Path") in the JS Run tool? Does the Mac really use Path instead of PATH??
Enrique Zamudio
@chochos
Oct 18 2016 17:20
no
Tako Schotanus
@quintesse
Oct 18 2016 17:21
So why is that code there?
Enrique Zamudio
@chochos
Oct 18 2016 17:21
no idea
Tako Schotanus
@quintesse
Oct 18 2016 17:21
You wrote it ;)
Enrique Zamudio
@chochos
Oct 18 2016 17:21
I sure as hell didn't put that there,
i know it's PATH on mac (and linux and windows)
or maybe it's Path on windows?
Tako Schotanus
@quintesse
Oct 18 2016 17:23
Tsk, it's there from the very first version written by @tombentley
Not that I know of, I think it's PATH on all platforms
John Vasileff
@jvasileff
Oct 18 2016 17:24
it might actually be Path on windows; I thought I noticed that working through the VSCode stuff
Tako Schotanus
@quintesse
Oct 18 2016 17:27
Well problem is that on Windows it's case-insensitive, it might be Path or path or PATH, etc
ok, so System.getenv's parameter is case insensitive on windows
"On UNIX systems the alphabetic case of name is typically significant, while on Microsoft Windows systems it is typically not. For example, the expression System.getenv("FOO").equals(System.getenv("foo")) is likely to be true on Microsoft Windows."
Tako Schotanus
@quintesse
Oct 18 2016 20:44
@davidfestal for tomorrow: I just added those System properties I mentioned before ceylon.command.node and ceylon.command.npm. You should probably add those to the IDE somewhere before running anything related to JS (compiler, run, test etc). Especially because I removed some code that had a hard-coded list of directories to look for, so for some people it might have worked before and now suddenly won't. (Btw, for the CLI we just require that those executables must be in your PATH)
Not 100% how it should be handled: maybe the IDE can have some options for you to specify the path to those executables. Maybe it can look in the PATH and if it can't find them there warn the user and tell them how to fix it. Dunno.