Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've installed Ruby, RVM, and Jekyll following this tutorial and everything works fine after following those steps.

My issue is that each time I open a new terminal window and want Jekyll to rebuild the site with jekyll build, I get the error jekyll: command not found. The temporary solution is to re-run the following two commands from the tutorial then Jekyll works:

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile"

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

Checking that .profile file I noticed it says 'This file is not read by bash, if ~/.bash_profile or ~/.bash_login exists'. I ran the first two commands again substituting .bash_profile for .profile and this didn't seem to have any effect.

[[ -s "$HOME/.bash_profile" ]] && source "$HOME/.bash_profile"

I still get the Jekyll error and my .bash_profile file exists but is completely empty.

Is there a more permanent fix or am I stuck running the first two commands every single time I open a terminal to rebuild a site with Jekyll?

share|improve this question
    
I assume that jekyll add to .profile code, that add jekyll binaries to the $PATH. You should copy this part to .bash_profile. If you post here .profile, I will help you to understand it –  c0rp Apr 3 at 8:07
    
Also in tutorial you mentioned it is suggested to add this 2 line to your ~/.bash_profile. Just do it –  c0rp Apr 3 at 8:10
    
just add [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" in your .bashrc. It should solve the issue. –  souravc Apr 3 at 9:02

2 Answers 2

up vote 1 down vote accepted

~/.bashrc will be called for interactive + non-loginshell

whereas ~/profile will be called for interactive + login shell

The recommended way is putting

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" 

in the ~/.profile itself but in .bash_profile put source "$HOME/.profile.

And the second way way would be to add

`[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" `

in your .bashrc.

Here is why the second way is not much recommended.

More on .bashrc,.profile and bash_profile.

share|improve this answer
    
@TomBrossman you should never source .bashrc inside from .profile as .bashrc itself sources .profile. It will create an infinite loop like situation. Anyway Ctrl+C will give you back the terminal prompt. –  souravc Apr 3 at 8:59
1  
@TomBrossman Just go for the last one which is the one mostly used by most people –  Stormvirux Apr 3 at 9:12

You can create alias for the above three commands.

alias jekyllb='[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" && [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" && jekyll build'

Hence forth, whenever you would run jekyllb all the three commands would be run sequentially.

share|improve this answer
    
Thanks, this is clever but I would prefer to fix the problem rather than have to remember this command as a workaround. I'll forget about jelyllrb, read the official documantation, and be right back where I started. –  Tom Brossman Apr 3 at 8:46
    
@TomBrossman you can use something simpler like Tom or even a instead of jekyllb –  Registered User Apr 3 at 9:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.