Closed dan-dnz closed 2 years ago
One of our developers encountered a similar problem on his local machine when he didn't copy the config/application.yml.example to config/application.yml
It is quite a misleading error.
Try doing this:
cp config/application.yml.example config/application.yml
Hopefully that helps.
Thanks so much for your response, I already added the application.yml and used the application.yml.example as a reference but I can not see any configurations for the production environment here: https://github.com/DigitalNZ/supplejack_manager/blob/master/config/application.yml.example so I added my own application.yml and it looks like:
production:
WORKER_HOST: http://localhost:3002
WORKER_API_KEY: workerkey
API_HOST: http://localhost:3000
API_MONGOID_HOSTS: localhost:27017
However the above error is still there
Hey @michaelFakhry,
Thanks for getting back to us, I have found that I have been able to replicate your issue by providing only the production environment in the application.yml file and attempting to boot the rails console in development mode.
Can you try specifying the environment when you boot up the Rails console?
You can do that like this:
RAILS_ENV=production bundle exec rails c
Hope that helps,
Richard
Hi Richard,
Thanks for your reply, it worked great, but After that I started supplejcack_manager like so
RAILS_ENV=production bundle exec rails server -e production -p3001 > /path/to/my.log 2>&1 &
and after opening from browser it showed
We're sorry, but something went wrong.
in log file the error is
** [Honeybadger] Environment Info: [Ruby: 2.3.3] [Rails: 3.2.22.2] [Env: production]
** [Honeybadger] Response from Honeybadger:
{"error":"Invalid API key"}
method=GET path=/users/sign_in format=html controller=devise/sessions action=new status=500 error='ActionView::Template::Error: application.css isn't precompiled' duration=59.28 params={} time=2017-0
-05 19:36:10 +0000
ActionView::Template::Error (application.css isn't precompiled):
14: <meta name="viewport" content="width=device-width, initial-scale=1.0">
15: <title><%= content_for?(:title) ? yield(:title) : "Harvester Manager" %></title>
16: <meta name="description" content="<%= content_for?(:description) ? yield(:description) : "Harvester Manager" %>">
17: <%= stylesheet_link_tag "application", :media => "all" %>
18: <%= javascript_include_tag "application" %>
19: <%= csrf_meta_tags %>
20: <%= yield(:head) %>
app/views/layouts/application.html.erb:17:in `_app_views_layouts_application_html_erb__288780642325485357_31323120'
** [Honeybadger] Failure: Net::HTTPForbidden
Although I generated an API key in the previous step
-- Best regards Michael
Hey @michaelFakhry,
I am glad that that helped you out, it looks like there are two issues there. One is that Honeybadger isn't configured correctly. We no longer use Honeybadger so I have removed it from the repository, if you pull Master you will get that change now.
The other problem is that you will need to precompile your assets if you are intending on running the app production mode. This is usually done by your deployment tool, but if you are wanting to run the app locally in production mode, you will need to do this.
RAILS_ENV=production bundle exec rake assets:precompile
and then restart your application.
Also just a small thing, when you are running the app, you don't need to specify both the RAILS_ENV and the -e production, as I believe they do the small thing. Also Rails by default will log into the /log folder of the app and the file should be named by the environment you are running in, so you will be able to see the log in /log/production.log.
Hope that helps!
Richard
Hi Richard,
Once again Thanks this really helped, now the manager is working fine.
I am now working on running supplejack_api, I started by cloning the repo from github, then I tried executing:
RAILS_ENV=production bundle exec rails c
which resulted the following error:
/usr/local/rvm/gems/ruby-2.3.3/gems/dry-validation-0.10.3/lib/dry/validation/message_compiler.rb:13: warning: already initialized constant Dry::Validation::MessageCompiler::EMPTY_OPTS
/usr/local/rvm/gems/ruby-2.3.3/gems/dry-core-0.2.1/lib/dry/core/constants.rb:52: warning: previous definition of EMPTY_OPTS was here
Error: Command not recognized
Usage: rails COMMAND [ARGS]
The common Rails commands available for engines are:
generate Generate new code (short-cut alias: "g")
destroy Undo code generated with "generate" (short-cut alias: "d")
All commands can be run with -h for more information.
If you want to run any commands that need to be run in context
of the application, like `rails server` or `rails console`,
you should do it from application's directory (typically test/dummy).
I noticed in your template here:
that you are executing the command:
bundle exec rails generate supplejack_api:install --force --no-documentation
However I executed the following command:
RAILS_ENV=production bundle exec rails generate supplejack_api:install --force --no-documentation
which ended with the following error:
/usr/local/rvm/gems/ruby-2.3.3/gems/thor-0.19.1/lib/thor/actions/inject_into_file.rb:98:in `binread': No such file or directory @ rb_sysopen - /tmp/test/supplejack_api/app/assets/javascripts/applicat
on.js (Errno::ENOENT)
from /usr/local/rvm/gems/ruby-2.3.3/gems/thor-0.19.1/lib/thor/actions/inject_into_file.rb:98:in `replace!'
from /usr/local/rvm/gems/ruby-2.3.3/gems/thor-0.19.1/lib/thor/actions/inject_into_file.rb:59:in `invoke!'
from /usr/local/rvm/gems/ruby-2.3.3/gems/thor-0.19.1/lib/thor/actions.rb:94:in `action'
from /usr/local/rvm/gems/ruby-2.3.3/gems/thor-0.19.1/lib/thor/actions/inject_into_file.rb:30:in `insert_into_file'
from /tmp/test/supplejack_api/lib/generators/supplejack_api/install_generator.rb:95:in `add_assets'
from /usr/local/rvm/gems/ruby-2.3.3/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
from /usr/local/rvm/gems/ruby-2.3.3/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
from /usr/local/rvm/gems/ruby-2.3.3/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `block in invoke_all'
from /usr/local/rvm/gems/ruby-2.3.3/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `each'
from /usr/local/rvm/gems/ruby-2.3.3/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `map'
from /usr/local/rvm/gems/ruby-2.3.3/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `invoke_all'
from /usr/local/rvm/gems/ruby-2.3.3/gems/thor-0.19.1/lib/thor/group.rb:232:in `dispatch'
from /usr/local/rvm/gems/ruby-2.3.3/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
from /usr/local/rvm/gems/ruby-2.3.3/gems/railties-4.1.12/lib/rails/generators.rb:157:in `invoke'
from /usr/local/rvm/gems/ruby-2.3.3/gems/railties-4.1.12/lib/rails/commands/generate.rb:11:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-4.1.12/lib/active_support/dependencies.rb:247:in `require'
from /usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-4.1.12/lib/active_support/dependencies.rb:247:in `block in require'
from /usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-4.1.12/lib/active_support/dependencies.rb:232:in `load_dependency'
from /usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-4.1.12/lib/active_support/dependencies.rb:247:in `require'
from /usr/local/rvm/gems/ruby-2.3.3/gems/railties-4.1.12/lib/rails/engine/commands.rb:19:in `<top (required)>'
from script/rails:8:in `require'
from script/rails:8:in `<main>'
note that the application.js
does exist in /tmp/test/supplejack_api/app/assets/javascripts/supplejack_api
I tried working around this by manually copying the file
same happened with this file /tmp/test/supplejack_api/app/assets/stylesheets/application.css
I worked around this also by copying the file.
Finally I am able to execute RAILS_ENV=production bundle exec rails generate supplejack_api:install --force --no-documentation
successfully
But again same error when trying to execute RAILS_ENV=production bundle exec rails c
-- Best regards Michael
Hi Michael,
Sorry about the late reply, the supplejack_api project is not intended to be run standalone as it is a mountable engine, you will need to include it in a host Rails application.
You can do that by adding
gem 'supplejack_api', git: 'git@github.com:digitalnz/supplejack_api.git'
to your Gemfile, bundling the app, and then running the install command that you posted before.
Hope that helps, Richard
Posting this on behalf of an email to DigitalNZ:
I was working on a project that will be using supplejack as a search engine meanwhile I used
development
environment first which works fine and the supplejack components are up and running but that was for a few minutes, However since I need to use it in production environments I went back to the documentation and started installation on a fresh machine when I came onto this issue trying to generate an api key for the manager throughrails c
after I execute this command I come up with the following error