Author Topic: Path trouble when running vs from gnome  (Read 8579 times)

ssando

  • Community Member
  • Posts: 5
  • Hero Points: 0
Path trouble when running vs from gnome
« on: September 13, 2006, 10:59:59 PM »
Hi!

I'm a very long time user of VS.  However, I'm very new to Linux.  I created a desktop launcher for vs.

The trouble I'm having is using perforce from slickEdit.  Specifically, from the message it appears that vs can't find the p4 executable.

If I go to the build window in slickEdit and type p4 the command is found.  Also, if I launch vs from a terminal window it works fine.

I should note that my path setup is in ~/.bashrc.

It is as if when I launch vs from the desktop it is not reading my bashrc file.

Thanks,

Steve

Kohei

  • Senior Community Member
  • Posts: 192
  • Hero Points: 25
Re: Path trouble when running vs from gnome
« Reply #1 on: September 14, 2006, 02:21:17 PM »
Have you logged out and logged back in after you modified your .bashrc file?

The symptom that you described seems to me that you have modified your .bashrc but the modification has not taken effect for the whole desktop environment.  The .bashrc file gets read when 1) you open a new terminal window but the setting is only effective within that particular terminal window (which is why launching vs from the terminal picks up the setting in .bashrc), or 2) when you log in to your desktop.

So, before going any further, see if logging out and logging in fixes the problem for you.

--Kohei

ssando

  • Community Member
  • Posts: 5
  • Hero Points: 0
Re: Path trouble when running vs from gnome
« Reply #2 on: September 14, 2006, 02:38:49 PM »
Thanks,

OK I tried that and to no avail.

Here's the exact sequence:

Complete Reboot
Start vs from a 'Launcher' on the desktop
Right click on a file
Version Control/setup
Select perforce
"OK"
Message shows up and says "The following executables were not found: p4  ...  You may need to add them to your PATH.

I can ^i to the build window and type p4 and the program is found.

Thanks for any ideas,

Steve

Kohei

  • Senior Community Member
  • Posts: 192
  • Hero Points: 25
Re: Path trouble when running vs from gnome
« Reply #3 on: September 14, 2006, 02:56:15 PM »
Can you type the command which p4 in a terminal window and post what it says?  I just need to know where the p4 command is.

Also, after launching SlickEdit from the launcher on your desktop, can you type set in the SlickEdit command line and see what the value of PATH is?

ssando

  • Community Member
  • Posts: 5
  • Hero Points: 0
Re: Path trouble when running vs from gnome
« Reply #4 on: September 14, 2006, 03:51:41 PM »
I launched a terminal from the desktop and:

ssando@STEVED820:~$ which p4
/usr/local/tools/i686_Linux/bin/p4
ssando@STEVED820:~$
ssando@STEVED820:~$ echo $PATH
/home/ssando/bin:/usr/local/tools/common/bin:/usr/local/tools/i686_Linux/bin:/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games:/opt/slickedit/bin
ssando@STEVED820:~$

Steve

Kohei

  • Senior Community Member
  • Posts: 192
  • Hero Points: 25
Re: Path trouble when running vs from gnome
« Reply #5 on: September 14, 2006, 04:29:31 PM »
Thanks, Steve. :-)

I actually meant to say the set command from the SlickEdit command line, not from the terminal.  Sorry I wasn't clear on this.  This command will actually show all the environment variables that SlickEdit inherits from the desktop environment, including your PATH.  So, if the SlickEdit version of PATH doesn't include the path where p4 is located, SlickEdit is somehow inheriting the PATH setting incorrectly.

To invoke the SlickEdit command line, press ESC, then type set and press ENTER.  Then check the value of PATH and let us know.

You could also try using the full path to p4 in the Perforce setting dialog to see if that works.  To do it, follow these steps:

  • Go to Tools > Version Control > Setup...
  • Select Perforce and Click Setup...
  • Select Add command, and replace its default value "p4 add %f" with "/usr/local/tools/i686_Linux/bin/p4 add %f"
  • Hit OK to exit.

Thanks,
Kohei
« Last Edit: September 14, 2006, 05:29:51 PM by Kohei »

ssando

  • Community Member
  • Posts: 5
  • Hero Points: 0
Re: Path trouble when running vs from gnome
« Reply #6 on: September 14, 2006, 08:24:44 PM »
I'm sorry, that make sense... (great command btw I was wondering how to see that information since the build window starts a shell.)

OK here it is and the part I want is missing:

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games


OK, if you don't mind a Linux question now...

Why doesn't the desktop run .bashrc?
Where should I set my path (and other stuff) so that slickEdit will have all the variables I want.

I suppose that's two questions  ;)

Steve

Kohei

  • Senior Community Member
  • Posts: 192
  • Hero Points: 25
Re: Path trouble when running vs from gnome
« Reply #7 on: September 15, 2006, 12:45:50 AM »
Quote
Why doesn't the desktop run .bashrc?
Actually it does in some distros, at least in Red Hat Enterprise Linux and (Open)SUSE Linux.  But in certain distros it doesn't.  For instance in the version of Ubuntu I have here, .bashrc doesn't seem to get sourced at login time (I just found out today).

The reason against sourcing .bashrc at login time for the whole desktop environment may be that .bashrc, in the most strict sense, is a resouce file for bash shell environment, and the graphical desktop environment does not depend on bash, nor is it a child process of bash.  It is also possible that the user may be using a different shell, such as tcsh or zsh.  In that view, it may not make sense to source .bashrc. for a process that has no relation to bash.  But in reality many distros do it, and that's probably done for convenience (don't quote me on that, though :-).

What exactly happens at login time is also highly distribution & environment specific; that is, the desktop environment (DE) you choose (KDE, Gnome, etc.) and the login manager you use (xdm, gdm, or kdm) may influence what commands get run, what resource files get sourced, that sort of stuff.

What Linux distribution are you using, BTW?

Quote
Where should I set my path (and other stuff) so that slickEdit will have all the variables I want.
There are several ways to do this.  But perhaps the easiest IMO is to write a wrapper script that sources your .bashrc and start vs afterwards, and have your launcher point to that wrapper script.

The following script will probably work:

Code: [Select]
#!/bin/bash

VSEXEC=/opt/slickedit/bin/vs    # <- point this to your vs location
source ~/.bashrc
$VSEXEC $@

and make sure this script has an execute permission set, or it won't run.  To set the execution bit on, run the following command:

Code: [Select]
chmod +x {script name}

Once this is done, go to the Properties of your launcher file (right-click) and change the command to point to this script, instead of the original vs binary.  That should do the trick.

Let us know how that goes. :-)

--Kohei
« Last Edit: September 15, 2006, 05:43:23 AM by Kohei »

ssando

  • Community Member
  • Posts: 5
  • Hero Points: 0
Re: Path trouble when running vs from gnome
« Reply #8 on: September 15, 2006, 02:43:40 PM »
Yeah I'm running ubuntu too.  You're explaination is very helpful, thanks.

However you example script didn't change anything - still no environment variables from .bashrc.  For fun I tried the direct approach of setting path in the launch script as a test (not a good solution):

Code: [Select]
#!/bin/bash

VSEXEC=/opt/slickedit/bin/vs    # <- point this to your vs location
export PATH="$PATH:/usr/local/tools/common/bin:/usr/local/tools/i686_Linux/bin"

$VSEXEC $@

Crazy but that works.  I don't understand 'source' I guess.  Or there is something in my .bashrc that prevents it.

Next I try this:

Code: [Select]
#!/bin/bash

VSEXEC=/opt/slickedit/bin/vs    # <- point this to your vs location
$VSEXEC $@


But I set the launcher to 'run in a terminal' session.  For sure that will work,because it starts in a terminal.  Nope!?

Any ideas?

Steve

« Last Edit: September 15, 2006, 02:45:24 PM by ssando »

Kohei

  • Senior Community Member
  • Posts: 192
  • Hero Points: 25
Re: Path trouble when running vs from gnome
« Reply #9 on: September 15, 2006, 04:20:51 PM »
Hi Steve,

Quote
However you example script didn't change anything - still no environment variables from .bashrc.
As it turned out, Ubuntu's .bashrc file is a lot different than what I'm used to seeing. :(  There is this following line:
Code: [Select]
#If not running interactively, don't do anything
[ -z "$PS1" ] && return

near the top which immediately exits when the file is exec'ed or sourced from a process other than bash interactive shell.  This means that, you could put your custom PATH setting before this line, then my example script should pick up your custom PATH setting.

Quote
Code: [Select]
#!/bin/bash

VSEXEC=/opt/slickedit/bin/vs    # <- point this to your vs location
export PATH="$PATH:/usr/local/tools/common/bin:/usr/local/tools/i686_Linux/bin"

$VSEXEC $@
This should work too.  Not a crazy solution by the way, a good one. :-)

Quote
I set the launcher to 'run in a terminal' session.
This didn't work for me when I tested it.  My guess is that this checkbox is probably there in case you need to capture standard output from the application, not to invoke the shell.

--Kohei