Desktop Files don't seem to use $PATH correctly

Solution 1:

The tilde doesn't get expanded in .pam_environment the way it would in a profile script, and desktop files don't do shell expansion on their Exec lines the way the shell would, so it's looking for a file that's literally named ~/usr/bin/eclipse, which of course doesn't exist.

Replace the tilde in the PATH assignment with ${HOME} and it seems to work.

Solution 2:

What is said on the Ubuntu documentation makes sense, however its "not recommended anymore" section is lacking in some details. For that reason, my answer will involve using one of these methods. Also: it is already used for this exact same purpose.

Take a quick visit to your ./.profile file.

Mine contains this:

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

As you can see by the last section of this file (lines below # set PATH so it includes user's private bin if it exists), this is already being done. So if you wanted to add something to the $PATH variable, you would simply do the same thing. The documentation did mention that this will be run every time the system is started.

In your case, all you would need to do is add this:

# set PATH to custom variable (this line is not needed)
if [ -d "$HOME/usr/bin" ]; then
    PATH="$HOME/usr/bin:$PATH"
fi

At this point I am starting to think that the only reason that this method is not recommended anymore is it involves scripting on startup, which is very sensitive to slight mistakes. When someone is working with something like this, however, a small mistake could be undone simply by changing the file back to the way it was.

If you are not sure how to do this:

1) First, press CTRL+ALT+F3

2) Log in by following the onscreen prompt

3) Type this into the command prompt:

/usr/bin/nano ./.profile

4) remove these lines: (we just added them)

# set PATH to custom variable (this line is not needed)
if [ -d "$HOME/usr/bin" ]; then
    PATH="$HOME/usr/bin:$PATH"
fi

5) press CTRL+O (as in Out)

6) press CTRL+X (as in eXit)

7) type exit and press ENTER (sometimes RETURN)

8) now press CTRL+ALT+F7

9) You should get your login screen or desktop, depending on when the problem occured. If not, press CTRL+ALT+DEL (sometimes CTRL+ALT+DELETE) and your system should restart safely.

Hope this helps!