-1

I am trying to intergrate Gams and Matlab following this video

The problem, however, is that MATLAB cannot see Gams using system command. More precise, I get an error:

/bin/bash: gams: command not found

My Gams installation folder is

/home/username/Gams/gams24.5_linux_x64_64_sfx

So, how can I say to MATLAB to run Gams from my home folder?

Yorgos
  • 183
  • 10
  • This is not a matlab question. You have to add the location of `gams` to your unix path. If you can run `gams` from the terminal as `gams`, then you can do the same from matlab. See [here](http://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path) for instance. – Andras Deak -- Слава Україні Dec 27 '15 at 15:35
  • i can run `gams` from terminal as `gams` without any problem. However, when I open matlab and run `system 'gams ? lo=3'` i get the above error – Yorgos Dec 27 '15 at 15:37
  • Are you running matlab from the same directory as where the call works in bash? Have you restarted matlab since installing gams? Have you tried `system('gams ? lo=3')`? `echo $PATH` in bash and `system('echo $PATH')` in matlab should give the same result. Do they? – Andras Deak -- Слава Україні Dec 27 '15 at 15:40
  • matlab's running directory is `/usr/local/bin/matlab'. I have also set the path in matlab of my gams running directory, but either `system('gams ? lo=3')` command produces the above error. – Yorgos Dec 28 '15 at 16:55
  • I'm pretty sure a `system` call will not look for the matlab path: it spawns a shell process, so the executable should be on your `$PATH`. That's why I asked: what do `echo $PATH` (in bash) and `system('echo $PATH')` (in matlab) return? – Andras Deak -- Слава Україні Dec 28 '15 at 17:24
  • both two commands return `/opt/texbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games` – Yorgos Dec 28 '15 at 23:32
  • The location of `gams`, which is `/home/username/Gams/gams24.5_linux_x64_64_sfx`, is not on your unix path, so you can't run it by just saying `gams`. Actually, it shouldn't work from the terminal either. Just to check: try `cd ~/Gams/gams24.5_linux_x64_64_sfx;` in matlab, then again try running `gams`. If it works: add the `gams` installation directory to your path, as I said in my first comment. – Andras Deak -- Слава Україні Dec 28 '15 at 23:40
  • I tried to reinstall gams into my system's directory. Now `echo $PATH` sees gams (`/opt/texbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/gams/gams24.5_linux_x64_64_sfx `), but system('echo $PATH') does not (`/opt/texbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games `) – Yorgos Dec 29 '15 at 00:44
  • Have you restarted matlab since the reinstall? – Andras Deak -- Слава Україні Dec 29 '15 at 00:49
  • yes... but still matlab doesn't recognise it. I also added the new installation path into maltab, but nothing happened – Yorgos Dec 29 '15 at 00:54
  • I don't know what it's wrong... I guess I will give up! Thank you very much for your time and effort :) :) :) – Yorgos Dec 29 '15 at 00:56
  • Wait. The unix path is also shell-dependent. Start up a *new* shell, and start matlab from there. If that *also* doesn't help, I'll give up as well:) – Andras Deak -- Слава Україні Dec 29 '15 at 00:56
  • ok... that's quite strange. I always started matlab from launcher. Now, I started from the terminal and now it recognizes gams. Everything seems to work perfectly. Probably it was that shell-dependence that you previously mentioned – Yorgos Dec 29 '15 at 01:01
  • You are a true life saver!!!! :) :) :) – Yorgos Dec 29 '15 at 01:02
  • No problem. I think if you restart the whole computer, everything should be OK. Good luck:) – Andras Deak -- Слава Україні Dec 29 '15 at 01:03

1 Answers1

0

Disclaimer: (This question was solved in the comments: in the spirit of a comment in this thread, which fits because GAMS users are generally new to computing, this is just a reformulation of what was discussed in the comments.

Since system command spawns a shell, the error is coming directly from the shell output. The error reads "/bin/bash: gams: command not found". Which is a clear indication that the gams binary is not recognized as a valid shell command. Most of the times, what happens is that the gams binary isn't registered in that shell $PATH variable.

The easiest way to solve this (if that is the problem) is to reinstall gams (it offers the option to add it to $PATH). More elegant ways involve adding the binary to $PATH

Community
  • 1
  • 1
cladelpino
  • 337
  • 3
  • 14