RefineryCMS image uploading error, ImageMagick CentOS 5.5 - imagemagick

I installed RefineryCMS on my server(CentOs 5.5) and everything works fine except uploading images. It will show an error like:
NoMethodError in Refinery::Admin::ImagesController#create
undefined method `downcase' for nil:NilClass
I installed ImageMagick by typing:
sudo yum install ImageMagick
I searched online and it seems ImageMagick installed by yum is too old (Version 6.2.x)
Then I removed it, successfully installed ImageMagick v6.7.7 from source code.
Now when I try to upload an image, refinery shows:
Dragonfly::Shell::CommandFailed in Refinery::Admin::ImagesController#create
Command failed (identify '/tmp/RackMultipart20120628-29239-70xr45') with exit status 127
However, if I run that command "identify '/tmp/RackMultipart20120628-29239-70xr45'" in the command line, it will show the result without any error. It seems that Dragonfly can not pick up my installation of the lastest version of ImageMagick. Could any one tell me how to configure it ? Or should I upgrade my centOS ?(I wish not)

Well, I have struggled with this issue for more than one week.
I also asked this question in Github and finally got the solution there.
see: https://github.com/resolve/refinerycms/issues/1781#issuecomment-6823858
Since this problem is caused by that Dragonfly can not find imagemagick.
You can try add the following code to config/application.rb
initializer 'override-image-magick-paths', :after => 'attach-refinery-images-with- dragonfly' do
app=Dragonfly[:refinery_images]
app.configure_with(:imagemagick)
app.configure do |c|
c.convert_command = "/usr/local/bin/convert" # defaults to "convert"
c.identify_command = "/usr/local/bin/identify" # defaults to "identify"
end
end
Modify the path according to your imagemagick installation.
You can use which command to find the path. e.g. which convert
However, this still doesn't work for me.
And finally, toymachiner62 find a solution which is simple and works perfect.
That is to use symbolic link:
$ cd /usr/bin
$ ln -s /usr/local/bin/convert convert
$ ln -s /usr/local/bin/identify identify
modify the /usr/local/bin/convert paths to you installation as well.
This looks like my /usr/local/bin path is not in my $PATH, but actually it is.
Dragonfly just seems can not find it anyway.

Related

Installing imagemagick using homebrew -- can't find command

I tried installing imagemagick using homebrew on a Mac. Specifically, I did:
brew install imagemagick
in terminal. There were no error messages. When I go to use imagemagick, e.g. using the command:
magick convert
I don't see the magick command available when I try to tab complete. I'm a bit uncertain how to debug this -- it seems like it should have installed fine?
As part of installing homebrew you need to set your PATH so your shell knows where the executable binaries are installed.
Depending on your homebrew version and macOS hardware and software, you may need:
export PATH=/opt/homebrew/bin:$PATH
or
export PATH=/usr/local/bin:$PATH
You can tell which of the two commands above you need with:
find {/opt/homebrew,/usr/local}/bin -name magick
Then run:
hash -r
and all homebrew commands like magick should work for your current session.
If you want the PATH set correctly for all future sessions you will need to add the export command from above to your login profile. That will depend on your shell, but is probably:
$HOME/.zprofile
or
$HOME/.profile
Note that you should read this answer to understand why you do NOT want to use magick convert.

Ghostscript installed but not found RGhost::Config::GS[:path]='/path/to/my/gs'

I've been trying for a few hours now solve this problem and I looked everywhere for a solution and I did not find one. I'm trying to run a spec test for my project and I have the following error coming up:
RuntimeError:
Ghostscript not found in your system environment (linux-gnu).
Install it and set the variable RGhost::Config::GS[:path] with the executable.
Example: RGhost::Config::GS[:path]='/path/to/my/gs' #unix-style
RGhost::Config::GS[:path]="C:\\gs\\bin\\gswin32c.exe" #windows-style
And I do try to put RGhost::Config::GS[:path]='/usr/local/bin/gs' and it returns:
bash: RGhost::Config::GS[:path]=/usr/local/bin/gs: No such file or directory
but ghostscript is installed, I did everything (make, sudo make install, etc etc) and when I run gs -v it returns:
GPL Ghostscript 9.26 (2018-11-20)
Copyright (C) 2018 Artifex Software, Inc. All rights reserved.
When I use the user interface and search for "gs" in the "Files" application, it is found in /home/marcelle/projects/ghostscript-9.26/bin/gs and I also tried:
RGhost::Config::GS[:path]='/home/marcelle/projects/ghostscript-9.26/bin/gs'
and it returns the same error:
bash: RGhost::Config::GS[:path]=/home/marcelle/projects/ghostscript-9.26/bin/gs: No such file or directory
I also tried to delete ghostscript from my notebook with autoremove and purge and installed it again using what I mentioned before (./configure, make, sudo make install), restarted the notebook, the terminal and nothing.
PS: I'm using Ubuntu 20.04.
I managed to figure out a solution. Looking for the code for the Rghost, what I saw in its spec is that the path expected was different than the path the ghostscript really is.
When I run whereis or which on my terminal, it returns:
which gs
/usr/local/bin/gs
So I was trying to point to this path. But seeing the spec test for Rghost which I found on github for Rghost, we can see that it expects /usr/bin/gs:
it 'should detect linux env properly' do
RbConfig::CONFIG.should_receive(:[]).twice.with('host_os').and_return('linux')
File.should_receive(:exists?).with('/usr/bin/gs').and_return(true)
RGhost::Config.config_platform
RGhost::Config::GS[:path].should == '/usr/bin/gs'
end
So it expects /usr/bin and not /usr/local/bin.
Then I just copied to that path and the spec ran with no problems anymore:
sudo cp /usr/local/bin/gs /usr/bin
I've no experience with Ruby at all, but I also got this error when using asciidoctor, which uses rghost for the PDF generation.
The command RGhost::Config::GS[:path]='/path/to/my/gs' mentioned in the error is not a shell command, which is why bash couldn't handle it. However, to me it wasn't immediately clear what to do with this command either. I expected an easy way to set this variable somewhere, but couldn't find it.
What worked for me was searching the rghost.rb file, which is where this variable is set and can be changed. In Windows, it was located in C:\Ruby30-x64\lib\ruby\gems\3.0.0\gems\rghost-0.9.7\lib\rghost.rb.
In this file, I added the following line, which solved the problem:
RGhost::Config::GS[:path]="C:\\Program Files\\gs\\gs9.55.0\\bin\\gswin64c.exe"
NB: the mentioned paths can be different for everyone, so make sure to use that paths that are valid for your system.

Node.js not found by Rails / execjs

I have node.js installed by compiling and installing it from the root user. I think this maybe where the hangup is. From the user running the rails app I checked for node.js.
$ which node
/usr/local/bin/node
When I launched my rails app (Rails 3.2.9) I get the universally unhelpful "We're sorry, but something went wrong." Checking the the production error log I saw that the Javascript runtime was not found. That's confusing as it is obviously installed. So I went about forcing the Node javascript runtime. I edited config/boot.rb to include:
ENV['EXECJS_RUNTIME'] = 'Node'
I checked my app again, while watching the production log. This time I got the error
ActionView::Template::Error (Node.js (V8) runtime is not available on this system
Still confused. I went to the execjs gem and changed the runtime command to the exact installed path.
Node = ExternalRuntime.new(
:name => "Node.js (V8)",
:command => "/usr/local/bin/node",
:runner_path => ExecJS.root + "/support/node_runner.js",
:encoding => 'UTF-8'
)
I still get the same error. Node is installed and accessible by the user but the gem/rails can't seem to use it.
The server is run CentOS 6.3. The specific javascript file causing the error to be thrown is jquery.nivo.slider.pack.js. Which I didn't edit after downloading it from nivo.
So, I have Ruby 2.0.0 installed and Rails 4.0.2 on CentOS 5.10 using Apache2 with Passenger. My first step I tried was opening the rails console and typing in the following command:
ExecJS.runtime
It returned the following value:
#<ExecJS::ExternalRuntime:0x99ab380 #name="Node.js (V8)", #command=["nodejs", "node"],#runner_path="/home/foo/vendor/bundle/ruby/2.0.0/gems/execjs-2.1.0
/lib/execjs/support/node_runner.js", #encoding="UTF-8", #deprecated=false, #binary="node">
Which meant that node was indeed installed and detected, but for some reason it was not working.
So, I tried the example on the website:
ExecJS.eval("'red yellow blue'.split(' ')")
and I got the correct response. So, now I am wondering why Passenger isn't picking it up.
Then, I noticed that passenger shows the path variable and it looks like:
/home/foo/vendor/bundle/ruby/2.0.0/bin:/usr/local/rvm/gems/ruby-2.0.0-p481/bin:/usr/local/rvm/gems/ruby-2.0.0-p481#global/bin:/usr/local/rvm/rubies/ruby-2.0.0-p481/bin:/usr/kerberos/bin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/rvm/bin:/home/foo/bin
But, it seems to be missing the usr/local/bin. I'm no expert on Linux, so for me the easiest way to fix this is with a symbolic link. So, I execute ln -s /usr/local/bin/node /usr/bin/node. You may want to note that I found the path to my nodejs using the command find / -name node.
I then refreshed my web application and wouldn't you know it worked. So, if it worked for me I am hoping that it can help someone else out.
UPDATE (Probably Better Way): This is probably a better way to do it. We can compile it from source like so:
mkdir ~/install
cd ~/install
wget https://nodejs.org/dist/v7.2.1/node-v7.2.1.tar.gz
tar xvf node-v7.2.1.tar.gz
cd node-v7.2.1
./configure --prefix=/usr/
make && make install
This way Node.js will be installed in the path where Passenger expects it to be.
I have had similar issue installing nodejs with source on my centos 6.3 system. It was successfully installed but I keep failing in compiling my ror app assets until I explicitly set the PATH to where it was installed (nodejs)
[root]# make install
...
installing /usr/local/lib/node_modules/npm/html/doc/folders.html
symlinking ../lib/node_modules/npm/bin/npm-cli.js -> /usr/local/bin/npm
updating shebang of /usr/local/bin/npm to /usr/local/bin/node
[root]# export PATH=/usr/local/bin:$PATH
Now it works. Hope that helps!
I don't know if this will help but check your $PATH that node is in there. Also, you should be using rvm if you want to use node. Check that your node install is done correctly.

Photo is not recognized by the 'identify' command [duplicate]

I'm getting the following error in my development.log
[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: /tmp/stream28514-0 is not recognized by the 'identify' command.>
And i've googled about this error and i found out that many people have solved this by adding this line
Paperclip.options[:command_path] = "/usr/local/bin"
However, i still get the same error even after adding that line! I've tried everything possible!
Any help would be highly appreciated!
Regards,
Punit
The Paperclip.options[:command_path] setting is for the location of your ImageMagick executables (in this case identify). Try running which identify and setting the option to be the directory that is returned. If that command doesn't return anything, make sure that ImageMagick is properly installed.
Here is what worked for me...
I uninstalled the imagemagick that i installed from the official webpage.
I reinstalled it from sudo apt-get install imagemagick
then i did write Paperclip.options[:command_path] = "to/correct/path"
THE PROBLEM HERE WAS...
when i ran "which identify" it appearde that the path was "usr/local/bin/identify"
it means that we I was supposed to put as a path "usr/local/bin" as my path.
BUT IT DIDN'T WORKED!
I surprisingly found that i identify was also in the "usr/bin" path. So i changed:
"usr/local/bin" to "usr/bin"
And that was all!
It means that it cannot find ImageMagick's executable identify on the location you specified in Paperclip.options[:command_path] (in your case /usr/local/bin).
This is tipically caused by two reason:
It might be that you actually did not installed ImageMagick.
SOLUTION: install it:
For MAC: sudo port install ImageMagick (which installs the binary release)
For UBUNTU: sudo sudo apt-get install imagemagick
It might be that the location where you installed ImageMagick is not /usr/local/bin but something else.
SOLUTION: find where it is installed, or via the command:
which identify (in case that identify is in the current PATH, as it should be)
or via a raw find through the file system:
find / -name identify
Anyway, the usual location for those file in Ubuntu should be /usr/bin
There are two possible problems:
Image Magick is not installed or broken
Paperclip is not able to find Image Magick
Let's take them one at a time:
1. Check you have Image Magick installed and it is working
Type:
identify
at the command line, it should work. If it isn't found, or fails to work, install Image Magick. Did this fix it? If not, continue:
2. Help Paperclip find Image Magick
Type:
which identify
at the command line to get the path to the identify command. Now, in production.rb, add the following line to the configuration block:
Paperclip.options[:command_path] = "/usr/bin"
Restart your server. That should fix it.
usr/bin worked me (Fedora 14 core)
Try running the identify command in the command line and see if that gives you some error message. I found out that my server was missing some delegate libraries.
identify example.jpg

Paperclip Error

I'm getting the following error in my development.log
[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: /tmp/stream28514-0 is not recognized by the 'identify' command.>
And i've googled about this error and i found out that many people have solved this by adding this line
Paperclip.options[:command_path] = "/usr/local/bin"
However, i still get the same error even after adding that line! I've tried everything possible!
Any help would be highly appreciated!
Regards,
Punit
The Paperclip.options[:command_path] setting is for the location of your ImageMagick executables (in this case identify). Try running which identify and setting the option to be the directory that is returned. If that command doesn't return anything, make sure that ImageMagick is properly installed.
Here is what worked for me...
I uninstalled the imagemagick that i installed from the official webpage.
I reinstalled it from sudo apt-get install imagemagick
then i did write Paperclip.options[:command_path] = "to/correct/path"
THE PROBLEM HERE WAS...
when i ran "which identify" it appearde that the path was "usr/local/bin/identify"
it means that we I was supposed to put as a path "usr/local/bin" as my path.
BUT IT DIDN'T WORKED!
I surprisingly found that i identify was also in the "usr/bin" path. So i changed:
"usr/local/bin" to "usr/bin"
And that was all!
It means that it cannot find ImageMagick's executable identify on the location you specified in Paperclip.options[:command_path] (in your case /usr/local/bin).
This is tipically caused by two reason:
It might be that you actually did not installed ImageMagick.
SOLUTION: install it:
For MAC: sudo port install ImageMagick (which installs the binary release)
For UBUNTU: sudo sudo apt-get install imagemagick
It might be that the location where you installed ImageMagick is not /usr/local/bin but something else.
SOLUTION: find where it is installed, or via the command:
which identify (in case that identify is in the current PATH, as it should be)
or via a raw find through the file system:
find / -name identify
Anyway, the usual location for those file in Ubuntu should be /usr/bin
There are two possible problems:
Image Magick is not installed or broken
Paperclip is not able to find Image Magick
Let's take them one at a time:
1. Check you have Image Magick installed and it is working
Type:
identify
at the command line, it should work. If it isn't found, or fails to work, install Image Magick. Did this fix it? If not, continue:
2. Help Paperclip find Image Magick
Type:
which identify
at the command line to get the path to the identify command. Now, in production.rb, add the following line to the configuration block:
Paperclip.options[:command_path] = "/usr/bin"
Restart your server. That should fix it.
usr/bin worked me (Fedora 14 core)
Try running the identify command in the command line and see if that gives you some error message. I found out that my server was missing some delegate libraries.
identify example.jpg

Resources