安装wp-scan时出现问题,特别是命令:
sudo gem install bundler && bundle install --without test
返回:
WARNING: You don't have /root/.gem/ruby/2.3.0/bin in your PATH,
gem executables will not run.
Successfully installed bundler-1.12.4
Parsing documentation for bundler-1.12.4
Done installing documentation for bundler after 5 seconds
1 gem installed
bash: bundle: command not found
我搜索过,似乎我没有设置Ruby路径,但是当我尝试使用“Setup”设置它时,bash返回:
-e:1: unexpected fraction part after numeric literal
/root/.gem/ruby/2.3.0/
^
这是.bashrc文件:
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
alias ls='ls --color=auto'
PS1='[\u@\h \W]\$ '
# >>>>BEGIN ADDED BY CNCHI INSTALLER<<<< #
BROWSER=/usr/bin/chromium
EDITOR=/usr/bin/nano
# >>>>>END ADDED BY CNCHI INSTALLER<<<<< #
#la riga inferiore serve a creare il path corretto di gem /ruby
PATH="$(ruby -e '/root/.gem/ruby/2.3.0/')/bin:$PATH"
我做错了什么?
这是gem env return:
RubyGems Environment:
- RUBYGEMS VERSION: 2.5.1
- RUBY VERSION: 2.3.1 (2016-04-26 patchlevel 112) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/2.3.0
- USER INSTALLATION DIRECTORY: /home/thecave3/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- SPEC CACHE DIRECTORY: /home/thecave3/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/lib/ruby/gems/2.3.0
- /home/thecave3/.gem/ruby/2.3.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--user-install"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/sbin
- /usr/local/bin
- /usr/bin
- /usr/bin/site_perl
- /usr/bin/vendor_perl
- /usr/bin/core_perl
- /root/.gem/ruby/2.3.0/bin
答案 0 :(得分:1)
将以下内容添加到.bashrc
应该可以解决问题:
export PATH="$PATH:/root/.gem/ruby/2.3.0/bin"
$(..)
是一个命令替换,它是一种从命令中捕获输出的方法:
a=$(echo 1234)
会将值1234
分配给a
,当然,使用a=1234
也可以实现同样的效果。
ruby -e '...'
将评估在-e
之后传递的代码,在您的情况/root/.gem/ruby/2.3.0/
中,它不是有效的Ruby代码,而是查找可执行文件的路径。
我还将Ruby路径添加到PATH
变量的末尾。这被认为是最好的方法,因为shell会搜索它以找到所需的程序。考虑一下:
~/bin % export PATH="$HOME/bin:/bin:/usr/bin"
~/bin % cat grep
#!/bin/sh
echo "got ya"
~/bin % grep '...' '...'
got ya