Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1625081 opened this issue Oct 12, 2017 · 2 comments
Open
Assignees

Comments

@1625081
Copy link

1625081 commented Oct 12, 2017

(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.....

@Eric-Guo
Copy link
Owner

Eric-Guo commented Oct 12, 2017

可能需要安装一下rails?

gem install rails

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

@1625081
Copy link
Author

1625081 commented Oct 12, 2017

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

@Eric-Guo Eric-Guo self-assigned this Oct 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants