Search code examples
ruby-on-railsrubyruby-on-rails-5runtime-errorghostscript

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.


Solution

  • 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