Closed dvodvo closed 9 months ago
However upon the execution of the io: StringIO.new(grover.to_pdf) command, the error referenced in the title emerges.
Are you saying that it works ok on localhost but NOT in some other environment? You seem to be missing some of the important details there if that's the case?
Can you provide a callstack of the error?
I'm only guessing here, but it seems likely that this is an environment setup issue. You may have setup node in your bash shell, but undoubtedly it has not been configured in your Ruby environment. You haven't provided any details about where or how you're actually executing the code you've referenced so I can't comment any further than this.
a) this isn't a puppeteer install issue.. it's an environment setup issue. Your Ruby environment doesn't know where Node is installed. But yes, each server wanting to call to Grover would need puppeteer installed. b) it isn't clear what you're talking about here. You clearly have something setup but you're assuming I know what it is! Typically you'd use a node package manager to install Puppeteer in the root of your Ruby project. c) No, this isn't an install or deployment issue.. your server has a messed up node environment..
Errno::ENOENT in IndividualsController#update No such file or directory - node
is bieng show upon method @individual.pdf_data.attach(io: StringIO.new(grover.to_pdf), filename: filename, content_type: 'application/pdf')
with the following stack trace
/home/ddeploy/.rbenv/versions/3.2.1/lib/ruby/3.2.0/open3.rb:222:in `spawn'
/home/ddeploy/.rbenv/versions/3.2.1/lib/ruby/3.2.0/open3.rb:222:in `popen_run'
/home/ddeploy/.rbenv/versions/3.2.1/lib/ruby/3.2.0/open3.rb:103:in `popen3'
grover (1.1.5) lib/grover/processor.rb:34:in `spawn_process'
grover (1.1.5) lib/grover/processor.rb:18:in `convert'
grover (1.1.5) lib/grover.rb:51:in `to_pdf'
app/controllers/individuals_controller.rb:442:in `render_pdf'
app/controllers/individuals_controller.rb:337:in `block in update'
actionpack (7.0.8) lib/action_controller/metal/mime_responds.rb:205:in `respond_to'
app/controllers/individuals_controller.rb:329:in `update'
actionpack (7.0.8) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (7.0.8) lib/abstract_controller/base.rb:215:in `process_action'
actionpack (7.0.8) lib/action_controller/metal/rendering.rb:165:in `process_action'
actionpack (7.0.8) lib/abstract_controller/callbacks.rb:234:in `block in process_action'
activesupport (7.0.8) lib/active_support/callbacks.rb:118:in `block in run_callbacks'
i18n (1.14.1) lib/i18n.rb:322:in `with_locale'
app/controllers/application_controller.rb:136:in `switch_locale'
activesupport (7.0.8) lib/active_support/callbacks.rb:127:in `block in run_callbacks'
actiontext (7.0.8) lib/action_text/rendering.rb:20:in `with_renderer'
actiontext (7.0.8) lib/action_text/engine.rb:69:in `block (4 levels) in <class:Engine>'
activesupport (7.0.8) lib/active_support/callbacks.rb:127:in `instance_exec'
activesupport (7.0.8) lib/active_support/callbacks.rb:127:in `block in run_callbacks'
activesupport (7.0.8) lib/active_support/callbacks.rb:138:in `run_callbacks'
actionpack (7.0.8) lib/abstract_controller/callbacks.rb:233:in `process_action'
actionpack (7.0.8) lib/action_controller/metal/rescue.rb:23:in `process_action'
actionpack (7.0.8) lib/action_controller/metal/instrumentation.rb:67:in `block in process_action'
activesupport (7.0.8) lib/active_support/notifications.rb:206:in `block in instrument'
activesupport (7.0.8) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (7.0.8) lib/active_support/notifications.rb:206:in `instrument'
actionpack (7.0.8) lib/action_controller/metal/instrumentation.rb:66:in `process_action'
actionpack (7.0.8) lib/action_controller/metal/params_wrapper.rb:259:in `process_action'
activerecord (7.0.8) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (7.0.8) lib/abstract_controller/base.rb:151:in `process'
actionview (7.0.8) lib/action_view/rendering.rb:39:in `process'
actionpack (7.0.8) lib/action_controller/metal.rb:188:in `dispatch'
actionpack (7.0.8) lib/action_controller/metal.rb:251:in `dispatch'
actionpack (7.0.8) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
actionpack (7.0.8) lib/action_dispatch/routing/route_set.rb:32:in `serve'
actionpack (7.0.8) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (7.0.8) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (7.0.8) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (7.0.8) lib/action_dispatch/routing/route_set.rb:852:in `call'
warden (1.2.9) lib/warden/manager.rb:36:in `block in call'
warden (1.2.9) lib/warden/manager.rb:34:in `catch'
warden (1.2.9) lib/warden/manager.rb:34:in `call'
rack (2.2.8) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.8) lib/rack/etag.rb:27:in `call'
rack (2.2.8) lib/rack/conditional_get.rb:40:in `call'
rack (2.2.8) lib/rack/head.rb:12:in `call'
actionpack (7.0.8) lib/action_dispatch/http/permissions_policy.rb:38:in `call'
actionpack (7.0.8) lib/action_dispatch/http/content_security_policy.rb:36:in `call'
rack (2.2.8) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.8) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/cookies.rb:704:in `call'
activerecord (7.0.8) lib/active_record/migration.rb:638:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (7.0.8) lib/active_support/callbacks.rb:99:in `run_callbacks'
actionpack (7.0.8) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/debug_exceptions.rb:28:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/show_exceptions.rb:29:in `call'
railties (7.0.8) lib/rails/rack/logger.rb:40:in `call_app'
railties (7.0.8) lib/rails/rack/logger.rb:25:in `block in call'
activesupport (7.0.8) lib/active_support/tagged_logging.rb:99:in `block in tagged'
activesupport (7.0.8) lib/active_support/tagged_logging.rb:37:in `tagged'
activesupport (7.0.8) lib/active_support/tagged_logging.rb:99:in `tagged'
railties (7.0.8) lib/rails/rack/logger.rb:25:in `call'
sprockets-rails (3.4.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/remote_ip.rb:93:in `call'
request_store (1.5.1) lib/request_store/middleware.rb:19:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/request_id.rb:26:in `call'
rack (2.2.8) lib/rack/method_override.rb:24:in `call'
rack (2.2.8) lib/rack/runtime.rb:22:in `call'
activesupport (7.0.8) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/server_timing.rb:61:in `block in call'
actionpack (7.0.8) lib/action_dispatch/middleware/server_timing.rb:26:in `collect_events'
actionpack (7.0.8) lib/action_dispatch/middleware/server_timing.rb:60:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/static.rb:23:in `call'
rack (2.2.8) lib/rack/sendfile.rb:110:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/host_authorization.rb:138:in `call'
railties (7.0.8) lib/rails/engine.rb:530:in `call'
/usr/lib/ruby/vendor_ruby/phusion_passenger/rack/thread_handler_extension.rb:107:in `process_request'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:157:in `accept_and_process_next_request'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:110:in `main_loop'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler.rb:419:in `block (3 levels) in start_threads'
/usr/lib/ruby/vendor_ruby/phusion_passenger/utils.rb:113:in `block in create_thread_and_abort_on_exception'
Yes, I assumed node was messed up somehow; it is a very opaque are for yours truly. Your Ruby environment doesn't know where Node is installed. : how can this be checked / adjusted?
Well you still haven't provided much in the way of details.. how are you actually running the Rails server? did you check that node was present in what ever script you have for starting Rails? (ie before you start Rails)
Did you set a default node version for NVM? If you don't it won't automagically just do that for you 😉 thus node would not be available in the Rails env.. https://github.com/nvm-sh/nvm?tab=readme-ov-file#set-default-node-version
I am a bit at a loss with how are you actually running the Rails server?
In a generic setup, dependencies were set up to compile ruby along with nodejs and yarn
sudo apt-get install git-core curl [...] nodejs yarn
then rbenv was installed for specific ruby versions. passenger
and nginx
then were installed for webserver requests.
De facto there is no script you have for starting Rails - passenger is simply started via tmp/restart.txt
nvm ls
-> v20.11.0
default -> v20.11.0
however, of note (from above link)
nvm use
No .nvmrc file found
Thus , should the the file be created at the root of the application (there are multiple applications) as such: echo "20.11" > .nvmrc
?
To anyone coming across such a situation, I proceeded by re-installing node and the ruby version required by the application, so that ruby be compiled against the newer node version
curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get install nodejs yarn
rbenv install 3.2.1
[confirm re-install]
ruby -v
> 3.2.1
On localhost the following generates files as expected:
However upon the execution of the
io: StringIO.new(grover.to_pdf)
command, the error referenced in the title emerges.Upon an initial deployment of the app with grover, the server had an older version of node, explaining another error. This was addressed in the following manner oin Ubuntu 20.04:
The relevant lines of .bashrc are
within the application's directory, node seems active.
what is missing in this approach?
additional thoughts
I had read the comment here https://github.com/Studiosity/grover/issues/149#issuecomment-1024823726 This phrase raised major question sregarding deployment:
installing puppeteer in your project root
a) should each server have pupetteer manually installed (in my case localhost is OS X, 1st remote server is Ubuntu) b) but where exactly? I am thinking in the shared directory, while .gitignore ignores the node-modules directory and the deploy process hasappend :linked_dirs, [...], 'node-modules'
c) if so, deployment issues would warrant a mention in the readMe