需要帮助从RVM切换到RBENV

时间:2016-04-02 19:41:48

标签: ruby

好吧所以我破坏了RVM并切换到了rbenv,但现在我觉得我在gem路径上遇到了各种各样的问题。我认为我的系统的某些部分仍然认为应该在RVM中找到宝石并且它会搞乱一切。我很难修复这样的配置问题,所以非常感谢你的帮助。

这是我的$ PATH:

/Users/home/.rbenv/shims:/Users/home/.rbenv/bin:/Users/home/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/home/.rvm/bin

所以你可以看到.rvm仍在$ PATH中,这是我的问题吗?我该如何解决?

这是我的宝石环境(这是我在手动移动一些目录以更好地匹配路径之前得到的,现在我得到相同的错误(下面) 当我运行ruby或bundle时:

RubyGems Environment:
  - RUBYGEMS VERSION: 2.2.2
  - RUBY VERSION: 2.1.2 (2014-05-08 patchlevel 95) [x86_64-darwin15.0]
  - INSTALLATION DIRECTORY: /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0
  - RUBY EXECUTABLE: /Users/home/.rbenv/versions/2.1.2/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/home/.rbenv/versions/2.1.2/bin
  - SPEC CACHE DIRECTORY: /Users/home/.gem/ruby/2.1.0
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-15
  - GEM PATHS:
     - /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0
     - /Users/home/.rbenv/versions/2.1.2/bin
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/home/.rbenv/versions/2.1.2/bin
     - /usr/local/Cellar/rbenv/0.4.0/libexec
     - /Users/home/.rbenv/shims
     - /Users/home/.rbenv/bin
     - /Users/home/.rbenv/shims
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /Users/home/.rvm/bin

我当前的ruby版本是2.1.2,它仍在调查2.1.0。

这是我的.bash_profile

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile

export PATH="$HOME/.rbenv/bin:$PATH"
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

这是我的.profile

eval "$(rbenv init -)"

当我运行ruby或bundle命令时,我收到此错误:

<internal:gem_prelude>:1:in `require': cannot load such file -- rubygems.rb (LoadError)
    from <internal:gem_prelude>:1:in `<compiled>'

我做了一些修补路径并手动重新定位了宝石目录,我觉得我弊大于利。谢谢您的帮助。如果您不知道答案可能有人请评论完全擦洗红宝石和宝石路径设置的最佳方法,以便我可以重新安装?我只是卸载rbenv吗?

2 个答案:

答案 0 :(得分:2)

我的RVM内爆脚本在这里 - 您可以根据需要进行编辑。

https://github.com/sixarm/rvm-implode-systemwide-danger

脚本在系统范围内进行RVM内爆,并且很危险。该脚本将搜索并销毁RVM安装,rvm gems,.rvmrc文件,然后在整个系统中搜索延迟文件和引用。

非常欢迎建议和拉取请求。我是作者。

整个脚本在下面复制/粘贴以供参考。上面的链接可能更好,因为它将有任何更新,更改,改进等。

// bluetoothAPI Middleware
import bluetoothService from 'bluetoothService';

export const DEVICE_SCAN = Symbol('DEVICE_SCAN'); // the symbol marks an action as belonging to this api

// actions creation helper for the middleware
const createAction = (type, payload) => ({ 
    type,
    payload
});

// This is the export that will be used in the applyMiddleware method
export default store => next => action => {
    const blueToothAPI = action[DEVICE_SCAN];

    if(blueToothAPI === undefined) {
        return next(action);
    }

    const [ scanDeviceRequest, scanDeviceSuccess, scanDeviceFailure ] = blueToothAPI.actionTypes;

    next(createAction(scanDeviceRequest)); // optional - use for waiting indication, such as spinner

    return new Promise((resolve, reject) => // instead of promise you can do next(createAction(scanDeviceSuccess, device) in the success callback of the original method
        bluetoothService.startDeviceSearch((device) => resolve(device), (error) = reject(error)) // I assume that you have a fail callback as well
        .then((device) => next(createAction(scanDeviceSuccess, device))) // on success action dispatch
        .catch((error) => next(createAction(scanDeviceFailure, error ))); // on error action dispatch
};

// Async Action Creator
export const startDeviceScan = (actionTypes) => ({
    [DEVICE_SCAN]: {
        actionTypes
    }
});

// ACTION_TYPES
export const SCAN_DEVICE_REQUEST = 'SCAN_DEVICE_REQUEST'; 
export const SCAN_DEVICE_SUCCESS = 'SCAN_DEVICE_SUCCESS'; 
export const SCAN_DEVICE_FAILURE = 'SCAN_DEVICE_FAILURE';

// Action Creators - the actions will be created by the middleware, so no need for regular action creators

// Applying the bluetoothAPI middleware to the store
import { createStore, combineReducers, applyMiddleware } from 'redux'
import bluetoothAPI from './bluetoothAPI';

const store = createStore(
  reducers,
  applyMiddleware(bluetoothAPI);
);

// Usage
import { SCAN_DEVICE_REQUEST, SCAN_DEVICE_SUCCESS, SCAN_DEVICE_FAILURE } from 'ACTION_TYPES';

dispatch(startDeviceScan([SCAN_DEVICE_REQUEST, SCAN_DEVICE_SUCCESS, SCAN_DEVICE_FAILURE]));

答案 1 :(得分:1)

确保您正在检查所有&#34; rc&#34;文件。这包括~/.bashrc~/bash_login(如果存在)。

使用像grep这样的工具可以帮助您找到它们。

grep 'rvm' -l ./.*也许,要获取任何对rvm的引用可能在的文件名。