【问题标题】:MissingSourceFile: cannot load such file -- net/scpMissingSourceFile: 无法加载此类文件 -- net/scp
【发布时间】:2014-01-11 04:09:35
【问题描述】:

自从将我的 Rails (2.3.17) 应用程序升级到 Ruby 1.9.3 后,我丢失了 ssh.sftp.upload! 方法,所以我尝试使用 net-scp 库,但我似乎无法使用它在 Rails 中。但是,在irb 中,我可以很好地要求文件,只是不在 Rails 控制台中。

me@app:~/myapp$ script/console myapp
Loading myapp environment (Rails 2.3.17)
>> require 'net/scp'
MissingSourceFile: cannot load such file -- net/scp
  from /path/to/myapp/shared/bundle/ruby/1.9.1/gems/activesupport-2.3.17/lib/active_support/dependencies.rb:184:in `require'
  from /path/to/myapp/shared/bundle/ruby/1.9.1/gems/activesupport-2.3.17/lib/active_support/dependencies.rb:184:in `require'
  from (irb):1
  from /home/me/.rvm/rubies/ruby-1.9.3-p448/bin/irb:16:in `<main>'

这似乎可行:

>> require 'net/ssh'
=> false

这是我的相关@​​987654325@

$ cat Gemfile.lock | grep "net-scp" -n5
30-      nokogiri (>= 1.4.4)
31-      uuidtools (~> 2.1)
32-    builder (2.1.2)
33-    capistrano (2.14.2)
34-      highline
35:      net-scp (>= 1.0.0)
36-      net-sftp (>= 2.0.0)
37-      net-ssh (>= 2.0.14)
38-      net-ssh-gateway (>= 1.1.0)
39-    capistrano-ext (1.2.1)
40-      capistrano (>= 1.0.0)
--
106-    multi_xml (0.5.3)
107-    mysql (2.9.0)
108-    net-http-digest_auth (1.2.1)
109-    net-http-persistent (2.8)
110-    net-ldap (0.3.1)
111:    net-scp (1.1.0)
112-      net-ssh (>= 2.6.5)
113-    net-sftp (2.1.1)
114-      net-ssh (>= 2.6.5)
115-    net-ssh (2.7.0)
116-    net-ssh-gateway (1.2.0)

我该如何解决或规避这个问题?

【问题讨论】:

    标签: ruby scp net-ssh


    【解决方案1】:

    显然它就像在Gemfile 中包含net-scp 一样简单,即使它包含在net-sshcapistrano 中。

    【讨论】:

    • 我已经有几天遇到类似的问题了。这也对我有用。我不太明白为什么它会起作用,但谢谢!
    • 很高兴它帮助了其他人。我的猜测是,除非将命名空间作为自己的 gem 包含在 Gemfile 中,否则该命名空间对 Rails 不可用。作为另一个 gem (capistrano) 的依赖项不会将依赖项冒泡到控制台的范围内,以便能够导入它,否则 gems 可能彼此不兼容。
    • 我不知道如何使用这个 anwser。我有一本厨师食谱,没有 Gemfile。唯一的版本控制文件是 metadata.rb 或 Berksfile.lock。将其添加到 Berksfile.lock 没有帮助。
    猜你喜欢
    • 1970-01-01
    • 2017-01-16
    • 2014-04-24
    • 2015-08-16
    • 1970-01-01
    • 1970-01-01
    • 2016-11-20
    • 2023-03-10
    • 2015-11-20
    相关资源
    最近更新 更多