wechat icon indicating copy to clipboard operation
wechat copied to clipboard

wechat 命令无法执行问题: uninitialized constant Rails (NameError)

Open 1625081 opened this issue 6 years ago • 2 comments

(erb):13:in `<main>': uninitialized constant Rails (NameError)
	from /home/z/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/erb.rb:896:in `eval'
	from /home/z/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/erb.rb:896:in `result'
	from /home/z/.rvm/gems/ruby-2.4.1/gems/wechat-0.8.12/lib/wechat/api_loader.rb:88:in `resovle_config_file'
	from /home/z/.rvm/gems/ruby-2.4.1/gems/wechat-0.8.12/lib/wechat/api_loader.rb:74:in `config_from_file'
	from /home/z/.rvm/gems/ruby-2.4.1/gems/wechat-0.8.12/lib/wechat/api_loader.rb:28:in `loading_config!'
	from /home/z/.rvm/gems/ruby-2.4.1/gems/wechat-0.8.12/lib/wechat/api_loader.rb:23:in `config'
	from /home/z/.rvm/gems/ruby-2.4.1/gems/wechat-0.8.12/lib/wechat/api_loader.rb:5:in `with'
	from /home/z/.rvm/gems/ruby-2.4.1/gems/wechat-0.8.12/bin/wechat:41:in `<class:App>'
	from /home/z/.rvm/gems/ruby-2.4.1/gems/wechat-0.8.12/bin/wechat:18:in `<top (required)>'
	from /home/z/.rvm/gems/ruby-2.4.1/bin/wechat:22:in `load'
	from /home/z/.rvm/gems/ruby-2.4.1/bin/wechat:22:in `<main>'
	from /home/z/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `eval'
	from /home/z/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `<main>'

最近看到了这个gem的介绍,感觉很好用,但是在命令行运行wechat 命令的时候总会遇到这个问题,而且一直debug不出来是哪里的问题,不过在rails console里可以正常使用。

所以到作者这里求个解决问题的思路quq.....

1625081 avatar Oct 12 '17 04:10 1625081

可能需要安装一下rails?

gem install rails

或者方便贴一下你的wechat.yml文件么?看起来你在yml文件里面写了Rails,系统试图找这个模块,但是找不到。

Eric-Guo avatar Oct 12 '17 06:10 Eric-Guo

default: &default
  # corpid: "corpid"
  # corpsecret: "corpsecret"
  # agentid:  1
# Or if using public account, only need above two line
  # appid: ""
  # secret: ""
  # token: "my_token"
  # access_token: "C:/Users/[username]/wechat_access_token"
  # encrypt_mode: false # if true must fill encoding_aes_key
  # encoding_aes_key:  "my_encoding_aes_key"
  # jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket"
  appid:    <%= Rails.application.secrets['wechat_appid']   %>
  secret:   <%= Rails.application.secrets['wechat_secret'] %>
  token:    <%= Rails.application.secrets['wechat_token'] %>
  timeout:    30,
  skip_verify_ssl: true
  encrypt_mode: false # if true must fill encoding_aes_key
  # encoding_aes_key:  Rails.application.secrets['wechat_access_token']
  # oauth2_cookie_duration: <%= ENV['WECHAT_OAUTH2_COOKIE_DURATION'] %> # seconds
  # below are save paths for files
  access_token:  <%= "#{Rails.root}/tmp/wechat_access_token" %>
  jsapi_ticket:  <%= "#{Rails.root}/tmp/wechat_jsapi_ticket" %>

production:
  # corpid:     <%= ENV['WECHAT_CORPID'] %>
  # corpsecret: <%= ENV['WECHAT_CORPSECRET'] %>
  # agentid:    <%= ENV['WECHAT_AGENTID'] %>
# Or if using public account, only need above two line
  appid:    <%= Rails.application.secrets['wechat_appid']   %>
  secret:   <%= Rails.application.secrets['wechat_secret'] %>
  token:    <%= Rails.application.secrets['wechat_token'] %>
  timeout:    30,
  skip_verify_ssl: true
  encrypt_mode: false # if true must fill encoding_aes_key
  # encoding_aes_key:  Rails.application.secrets['wechat_access_token']
  # oauth2_cookie_duration: <%= ENV['WECHAT_OAUTH2_COOKIE_DURATION'] %> # seconds
  # below are save paths for files
  access_token:  <%= "#{Rails.root}/tmp/wechat_access_token" %>
  jsapi_ticket:  <%= "#{Rails.root}/tmp/wechat_jsapi_ticket" %>

development:
  <<: *default
  trusted_domain_fullname: "http://your_dev.proxy.qqbrowser.cc"

test:
  <<: *default

1625081 avatar Oct 12 '17 12:10 1625081