Ruby 1.9.2 and Rails 3 cannot open rails console

前端 未结 10 1959
野性不改
野性不改 2020-12-01 06:04
[gkaykck@main myApplication]$ rails console
/usr/local/lib/ruby/1.9.1/irb/completion.rb:9:in `require\': no such file to load -- readline (LoadError)
    from /usr/l         


        
相关标签:
10条回答
  • 2020-12-01 06:48

    Adding in the Gemfile

    gem 'rb-readline'
    

    and then bundle install

    did the trick for me

    0 讨论(0)
  • 2020-12-01 06:51

    I'd recommend using rvm (Ruby Version Manager) to manage your different versions of Ruby and switch between them. It does a pretty good job of compiling the various versions for you too. You can even create per-directory .rvmrc files to tell rvm what version of ruby to use in which directory (as well as use per-project gem sets if you want!)

    0 讨论(0)
  • 2020-12-01 06:52

    With CentOS 6:

    Remember we are working from the ruby install dir, for me it was:

       /opt/ruby-1.9.3-p194/ext/readline
    

    If you see the following output, then readline is not installed:

    $ ruby extconf.rb 
    checking for tgetnum() in -lncurses... no
    checking for tgetnum() in -ltermcap... no
    checking for tgetnum() in -lcurses... no
    checking for readline/readline.h... no
    checking for editline/readline.h... no
    

    To install with RPM:

    yum install readline-devel
    

    Then build it:

    ruby extconf.rb 
    make
    sudo make install
    
    0 讨论(0)
  • 2020-12-01 06:54

    First of all uninstall every ruby version you have.

    After that display rvm requirements:

    rvm requirements
    

    You will get something like:

    Requirements for Linux ( DISTRIB_ID=Ubuntu
    DISTRIB_RELEASE=11.10
    DISTRIB_CODENAME=oneiric
    DISTRIB_DESCRIPTION="Ubuntu 11.10" )
    
    NOTE: 'ruby' represents Matz's Ruby Interpreter (MRI) (1.8.X, 1.9.X)   
    This is the *original* / standard Ruby Language Interpreter  
          'ree'  represents Ruby Enterprise Edition  
          'rbx'  represents Rubinius  
    
    bash >= 4.1 required curl is required git is required (>= 1.7 for
    ruby-head) patch is required (for 1.8 rubies and some ruby-head's).
    
    To install rbx and/or Ruby 1.9 head (MRI) (eg. 1.9.2-head), then you
    must install and use rvm 1.8.7 first.
    
    Additional Dependencies: 
    # For Ruby / Ruby HEAD (MRI, Rubinius, & REE), install the following:
      ruby: /usr/bin/apt-get install build-essential openssl libreadline6 
      libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev 
      libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev 
      ncurses-dev automake libtool bison subversion
    
    # For JRuby, install the following:
      jruby: /usr/bin/apt-get install curl g++ openjdk-6-jre-headless
      jruby-head: /usr/bin/apt-get install ant openjdk-6-jdk
    
    # For IronRuby, install the following:
      ironruby: /usr/bin/apt-get install curl mono-2.0-devel
    

    Install all dependencies via apt-get.
    After that install ruby 1.8.7. This version is required if you plan to use ruby 1.9.x
    Now you can install ruby 1.9.3:

    rvm pkg install readline
    rvm remove 1.9.3
    rvm install 1.9.3 --with-readline-dir=$rvm_path/usr
    

    Note that you dont even need to install readline package via rvm if you had installed it using apt-get.

    0 讨论(0)
提交回复
热议问题