Question

whenever I switch directory in my terminal, I have to run the command "/bin/bash --login" before I can run rails/rake related commands. If I don't, I get an error saying "the program "rails" can be found in the following packages: ..."

Any advice?

Was it helpful?

Solution

By default some servers do not allow this due to permissions reason. You can place this in ~/.bashrc and it will automatically work when you open a new terminal

As per bash man page.

When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists. This may be inhibited by using the --norc option. The --rcfile file option will force bash to read and execute commands from file instead of ~/.bashrc.

When bash is started non-interactively, to run a shell script, for example, it looks for the variable BASH_ENV in the environment, expands its value if it appears there, and uses the expanded value as the name of a file to read and execute. Bash behaves as if the following command were executed:

if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi but the value of the PATH variable is not used to search for the file name.

The file is just shell commands. It is typically used to change prompts, set environment variables, and define shell procedures. Traditionally, the file .profile is used for this purpose, but bash has so many extensions that it needs its own startup file for users that want to put bashisms in startup files.

OTHER TIPS

Easy solution:

Just open terminal. GO to Edit menu from terminal navigation bar, Select "Profile Preferences", It will open "edit profile pop-up". Select "Title and Command" button and "check Run Command as login shell"

ctrl + alt + t -> Edit -> Profile Preferences -> Title and Command -> Check Run command as login shell

Close the terminal and open again. Next time you don't need to "/bin/bash --login"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top