I'm working on a docker file to create a custom workspace on Codenvy . When I create the workspace everything seems to install correctly but when the workspace open and I enter ruby -v
I get:
bash: ruby: command not found
Same for rails:
user@de98ec223612:/projects$ rails -v
bash: rails: command not found
If I type rvm list I get
user@de98ec223612:/projects$ rvm info
ruby-2.4.0:
system:
uname: "Linux de98ec223612 3.10.0-514.10.2.el7.x86_64 #1 SMP Fri Mar 3 00:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux"
name: "Ubuntu"
version: "16.04"
architecture: "x86_64"
bash: "/bin/bash => GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)"
zsh: " => not installed"
remote path: "ubuntu/16.04/x86_64"
rvm:
version: "rvm 1.29.1 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io/]"
updated: "5 minutes 31 seconds ago"
path: "/home/user/.rvm"
autolibs: "[4] Allow RVM to use package manager if found, install missing dependencies, install package manager (only OS X)."
ruby:
interpreter: "ruby"
version: "2.4.0p0"
date: "2016-12-24"
platform: "x86_64-linux"
patchlevel: "2016-12-24 revision 57164"
full_version: "ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]"
homes:
gem: "/home/user/.rvm/gems/ruby-2.4.0"
ruby: "/home/user/.rvm/rubies/ruby-2.4.0"
binaries:
ruby: "/home/user/.rvm/rubies/ruby-2.4.0/bin/ruby"
irb: "/home/user/.rvm/rubies/ruby-2.4.0/bin/irb"
gem: "/home/user/.rvm/rubies/ruby-2.4.0/bin/gem"
rake: "/home/user/.rvm/rubies/ruby-2.4.0/bin/rake"
environment:
PATH: "/home/user/.rvm/gems/ruby-2.4.0/bin:/home/user/.rvm/gems/ruby-2.4.0@global/bin:/home/user/.rvm/rubies/ruby-2.4.0/bin:/usr/lib/jvm/java-1.8.0-open
jdk-amd64/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bundle/bin:/usr/lib/postgresql/9.6/bin:/home/user/.rvm/bin"
GEM_HOME: "/home/user/.rvm/gems/ruby-2.4.0"
GEM_PATH: "/home/user/.rvm/gems/ruby-2.4.0:/home/user/.rvm/gems/ruby-2.4.0@global"
MY_RUBY_HOME: "/home/user/.rvm/rubies/ruby-2.4.0"
IRBRC: "/home/user/.rvm/rubies/ruby-2.4.0/.irbrc"
RUBYOPT: ""
gemset: ""
which looks to me like things are installed correctly.
If I type /home/user/.rvm/rubies/ruby-2.4.0/bin/ruby -v
it shows the correct ruby version. /home/user/.rvm/rubies/ruby-2.4.0/bin
is in the PATH why isn't it being searched?
Here is the relevant portion of my docker file if that helps.
# Install RVM
RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB &&\
echo progress-bar >> ~/.curlrc &&\
\curl -sSL https://get.rvm.io | bash -s stable &&\
/bin/bash -l -c 'source ~/.rvm/scripts/rvm'
# Install Ruby
RUN /bin/bash -l -c 'rvm requirements' &&\
/bin/bash -l -c 'rvm install ${RUBY_VERSION}' &&\
/bin/bash -l -c 'rvm use ${RUBY_VERSION} --default' &&\
/bin/bash -l -c 'rvm rubygems current'
# Install bundler
RUN /bin/bash -l -c 'gem install bundler'
# Install Rails
RUN /bin/bash -l -c 'gem install rails'
RUN echo $PATH
EXPOSE 3000
WORKDIR /projects
CMD /bin/bash -l -c 'source ~/.rvm/scripts/rvm' && sudo service postgresql start && tail -f /dev/null
How can I get these commands to function without using /home/user/.rvm/rubies/ruby-2.4.0/bin
?
If acceptable to your team it is probably easier to start with the base dockerfile that Eclipse Che provides for RoR: https://github.com/eclipse/che-dockerfiles/blob/master/recipes/ruby_rails/Dockerfile
That should get you the basics and it's kept up-to-date by the community. You can then extend this with any other tools, libraries, deps you need.
I had the same problem and eventually I fixed it by uploading a /root/.bashrc file ending with
source /opt/rvm/scripts/rvm
source /etc/profile.d/ruby.sh
export PATH=$PATH:/opt/rvm/bin
The lines with source, are added by me. The export was added by RVM on install. The rest of my bashrc file is the content that was installed by Debian. I just added these lines.
My ruby.sh file contains
#!/bin/sh
export RUBY_HOME=/opt/rvm/rubies/default
For me, that does the trick. When I login using /bin/bash (non-shell) or via /bin/bash -l -c "command goes here", my commands rvm and ruby both respond. Also, my RUBY_HOME and GEM_PATH, ... are all filled.
My current ruby docker installation can be found here: https://github.com/vindevoy/dockerhub-debian-ruby (sources) https://hub.docker.com/r/vindevoy/debian-ruby/ (image)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.