Dropbox directory renaming resulting in 'URI::InvalidURIError: bad URI' on asset precompilation - ruby-on-rails-5

I just upgraded my Dropbox account from a personal account to a business account. As a result it changed my main dropbox name from just 'Dropbox' to 'Company Name Dropbox'.
Now when I try to either launch my rails app or do a rails assets:precompile I get the following error:
$ rails assets:precompile
yarn install v1.22.0
[1/4] 🔍 Resolving packages...
success Already up-to-date.
✨ Done in 0.15s.
rails aborted!
URI::InvalidURIError: bad URI(is not URI?): file-digest:///Users/name/Company Name Dropbox/Username/appfolder/jsp/app/assets/stylesheets/trestle/_variables.scss
/.rvm/gems/ruby-2.5.1#myapp/gems/sprockets-3.7.2/lib/sprockets/uri_utils.rb:45:in `split_file_uri'
/.rvm/gems/ruby-2.5.1#myapp/gems/sprockets-3.7.2/lib/sprockets/uri_utils.rb:126:in `parse_file_digest_uri'
/.rvm/gems/ruby-2.5.1#myapp/gems/sprockets-3.7.2/lib/sprockets.rb:159:in `block in <module:Sprockets>'
/.rvm/gems/ruby-2.5.1#myapp/gems/sprockets-3.7.2/lib/sprockets/dependencies.rb:67:in `resolve_dependency'
/.rvm/gems/ruby-2.5.1#myapp/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:23:in `block in initialize'
/.rvm/gems/ruby-2.5.1#myapp/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:59:in `resolve_dependency'
I have updated to the latest available version of Rails 5.2.4.3.
How do I resolve this without changing the location of my project? I need to leave it within my Dropbox folder.

I think you need to use URI.encode(url) so that the whitespace is converted to %20.

Related

Wicked_pdf not working with Heroku

I'm finishing a PDF report implementation for my application, which works perfectly in development mode, but when uploading to Heroku, it doesn't work, and I get the following error:
2011-10-24T03:28:02+00:00 app[web.1]: RuntimeError (Failed to execute:
2011-10-24T03:28:02+00:00 app[web.1]: /app/.bundle/gems/ruby/1.9.1/bin/wkhtmltopdf --header-html 'file:///app/tmp/wicked_header_pdf_1_0.html' --footer-html 'file:///app/tmp/wicked_footer_pdf_1_0.html' --orientation 'landscape' --page-size 'A4' --encoding 'UTF-8' -q - -
2011-10-24T03:28:02+00:00 app[web.1]: Error: PDF could not be generated!):
2011-10-24T03:28:02+00:00 app[web.1]: app/controllers/gliders_controller.rb:244:in `block (2 levels) in report'
2011-10-24T03:28:02+00:00 app[web.1]: app/controllers/gliders_controller.rb:228:in `report'
I've tried adding an initializer and manually uploading the wkhtmltopdf bin file to heroku following the example in this github repository, but I still can't get it to work.
I can't seem to grasp the exact reason why this wouldn't work in Heroku, could anyone give me a hand? Thanks in advance.
I got it to work. After a little searching, I found a github repo that implements a wicked_pdf initializer that works with Rails 3 and Heroku.
To make this work in your app:
Copy the bin directory to the root of your application
Copy the wickedpdf.rb into your config/initializers directory so that you get the same errors from heroku
Copy the "config.after_initialize do" statement from development.rb so that your local binary is found in development.
Heroku is a read-only filesystem and you're attempting to create a new file on that system. You cannot do this.
Using the wkhtmltopdf-binary gem will make wicked_pdf work in all environments. This takes away the need to manually install wkhtmltopdf on your local machine or on any production server.
gem install wkhtmltopdf-binary

as_paperclip_bridge initialization error in rails3

I'm trying to use both of PaperClip and ActiveScaffold with help of as_paperclip_bridge in a rails3.0.5 project.
However, following initialization error is occurred when I launch the project.
=> Booting WEBrick
=> Rails 3.0.5 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
C:/Users/ken/Documents/NetBeansProjects/fcheck/vendor/plugins/as_paperclip_bridge/init.rb:10: undefined method bridge' for ActiveScaffold:Module (NoMethodError)
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/plugin.rb:81
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/initializable.rb:25:ininstance_exec'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/initializable.rb:25:in run'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/initializable.rb:50:inrun_initializers'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/initializable.rb:49:in each'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/initializable.rb:49:inrun_initializers'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/application.rb:134:in initialize!'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/application.rb:77:insend'
from C:/Ruby187/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/application.rb:77:in method_missing'
from C:/Users/ken/Documents/NetBeansProjects/fcheck/config/environment.rb:7
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:inrequire'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in require'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:225:inload_dependency'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:596:in new_constants_in'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:225:inload_dependency'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in require'
from C:/Users/ken/Documents/NetBeansProjects/fcheck/config.ru:3
from C:/Ruby187/lib/ruby/gems/1.8/gems/rack-1.2.3/lib/rack/builder.rb:46:ininstance_eval'
from C:/Ruby187/lib/ruby/gems/1.8/gems/rack-1.2.3/lib/rack/builder.rb:46:in initialize'
from C:/Users/ken/Documents/NetBeansProjects/fcheck/config.ru:1:innew'
from C:/Users/ken/Documents/NetBeansProjects/fcheck/config.ru:1
The code in as_paperclip_bridge\init.rb is attempting to call a module method 'ActiveScaffold.bridge' but it coun't be found.
Even though, same code is working without error in rails2.3.8 project.
We can see a big difference of rails initialization code between version 2 and 3.
On rails 2.3.8, plugins are loaded in 'load_plugins' method which is called after 'load_gems' method in initializer.rb. However, rails3 doesn't have initializer.rb and the loading process seems to be totally different.
I also have tried to remove AS gem and install both of AS plugin with as_paperclip_bridge plugin. But, the error haven't disappeared.
Could someone explain why the error is occurring?!
Anyway, I really hope to get any solution or workaround.
Thanks,
Kenichi
Self reply.
I had realized that as_paperclip_bridge was not required for latest ActiveScaffold implementation. (It's including the bridge)
Please make sure to install ImageMagick and RMagick gem to use PaperClip for image files. Or, you may also think 'as_paperclip_bridge should be there'
Thank you,
Kenichi

Global access to Rake DSL methods is deprecated

I am working through the Ruby on Rails 3 tutorial book and typed the following on the command line:
rake db:migrate
which produced the following warning.
WARNING: Global access to Rake DSL methods is deprecated. Please Include
... Rake::DSL into classes and modules which use the Rake DSL methods.
WARNING: DSL method DemoApp::Application#task called at /Users/imac/.rvm/gems/ruby-1.9.2-p180#rails3tutorial/gems/railties-3.0.7/lib/rails/application.rb:215:in `initialize_tasks'
I am not sure what to do about it or how to work with it. I don't know any other command for Rake.
How can I fix this problem?
Adding include Rake::DSL to the Rakefile before the applications load_tasks were called also worked for me.
So in the above user's case before the DemoApp::Application.load_tasks in the Rakefile.
I found this in Stack Overflow question Ruby on Rails and Rake problems: uninitialized constant Rake::DSL. It refers to a #DHH tweet.
Put the following in your Gemfile
gem "rake", "0.8.7"
You may see something like
rake aborted!
You have already activated Rake 0.9.1 ...
I still had a copy of Rake 0.9.1 in my directory so I deleted it.
You can "delete" Rake 0.9.1 by running the following command:
gem uninstall rake -v=0.9.1
If you have multiple versions of the gem installed, you'll be prompted to pick a version.
After 0.9.1 was cleaned out, I ran
bundle update rake
and was finally able to create my database files. I was using rake db:create, but it should work for rake db:migrate as well.
I hope it helps.
I was having the same problem on Windows with the installer. Ruby 1.9.2 and Rails 3.0.9.
Here is what I did:
bundle update rake
bundle show rake
After doing that I was running rake 0.9.2.
Then I updated the Rakefile in application root folder as follows:
require File.expand_path('../config/application', __FILE__)
require 'rake'
# If you named your application something other than SampleApp, change that below
module ::SampleApp
class Application
include Rake::DSL
end
end
module ::RakeFileUtils
extend Rake::FileUtilsExt
end
SampleApp::Application.load_tasks
As noted in the comment, make sure the name of your app is correct in the two appropriate lines above.
If you are seeing this on later versions of Rails (like 3.+) you may also want to verify that your environment is clean by using RVM http://beginrescueend.com/ and creating a specific ruby & gemset for your projects.
Use an .rvmrc file on a per-project basis, this will guarantee you aren't getting older system gems into your projects. Which has bitten me before.
This prevents having to monkey around with generated Rakefiles & such.
bundle exec rake db:migrate will solve your ruby version issues

Heroku app crashes, logs say "No such file to load -- nokogiri (LoadError)"

I had a working app, added Nokogiri, to parse some xml, runs fine locally.
My Gemfile includes: gem 'nokogiri'
I ran bundle install and verified my Gemfile.lock includes DEPENDENCIES ... nokogiri
In my controller class I added (didnt thinkI had to but got an error locally if I didnt):
class MydealController < ApplicationController
require 'rubygems'
require 'open-uri'
require 'nokogiri'
when I use my browser to get the url in MydealController that uses nokogiri doc = Nokogiri::XML(getresult) Heroku crashes.
heroku logs shows this error No such file to load -- nokogiri (LoadError)
Looking at what happens when I git push heroku I do not see nokogiri on the list of many many gems that get installed. Heroku says the push was fine, but nokogiri is not listed and I get the aforementioned error...
It seems that when using Windows Gemfile.lock will contain version of nokogiri gem specific for windows, solution is to remove Gemfile.lock and push to heroku.
More info on this subject here
Your mission should you choose to accept it.
Ensure:
nokogiri is in Gemfile.lock
Gemfile.lock is committed to git
you push the commit that has nokogiri in Gemfile.lock to Heroku
Good luck! This message will self destruct in 10 seconds...
Just had the same problem -- you have to run bundle install to get it added to the Gemfile.lock which heroku looks at to find uninstalled dependencies.
This might help to understand the reason:
http://devcenter.heroku.com/articles/ps
Indeed removing Gemfile.lock might help. All other compiled gem will cause isseu. Best way is to ask Heroku's support.
Only found this article:
http://ganeshprasadsr.blogspot.com/2010/10/installing-nokogiri-for-rails-3-app-on.html
Try to remove require 'nokogiri' from controller.
It works for me.

Prologue with Ruby on Rails 3

I'm a total newbie to RoR and am trying to get the Prologue gem up and running. I've downloaded the prologue zip file from github.com/quickleft/prologue and am trying to follow the instructions in the associated readme file. I have encountered a number of issues....
Q1: What do I actually do with the extracted zip file? For instance, am I supposed to place the extracted files inside specific rails application directories or what ?
I've been able to install the gem by executing "gem install prologue". However, I cannot create a new application using the "prologue new my_app" command - the following message is displayed at the command prompt when I execute that command:
*C:/Ruby192/lib/ruby/gems/1.9.1/gems/prologue-0.3.10/lib/prologue/cli.rb:58:in ``
': No such file or directory - git config --global user.name (Errno::ENOENT)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/prologue-0.3.10/lib/prologue/cli.rb:58:in `git_user_name'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/prologue-0.3.10/lib/prologue/cli.rb:33:in new'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/task.rb:22 :inrun'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:118:in invoke_task'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor.rb:263:in dispatch'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/base.rb:38
9:instart'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/prologue-0.3.10/bin/prologue:4: in <top (required)>'
from C:/Ruby192/bin/prologue:19:inload'
from C:/Ruby192/bin/prologue:19:in `'*
Q2: Does anyone have any advice on how to overcome this problem?
Q3: Also, when attempting to get prologue up and running is it possible to do this without integrating it into an existing rails application? If so, how?
(I have ruby 1.9.2 and rails 3.0.0 installed on a Windows Vista machine)
Advice/feedback on the above issues would be greatly welcome!
It seems that Prologue needs 'thor', another gem. You can install all dependencies with the command 'bundle install'.
You can integrate Prologue in a new Rails app, but you definitely need some (existing or new) Rails app to run it.