WickedPDF not working in production server - ruby-on-rails

I am using wicked_pdf gem, it works fine in local machine, but in server its not working.
I have checked the process of wkhtmltopdf, It tries to run follwoing command
/usr/local/bin/wkhtmltopdf -q file:///tmp/wicked_pdf20150609-25535-im12hx.html tmp/wicked_pdf_xxx.pdf
When I run this command in server, I get this exception
Unable to load library icui18n "Cannot load library icui18n: (icui18n: cannot open shared object file: No such file or directory)"
I installed libicu48 package from here https://launchpad.net/ubuntu/trusty/amd64/libicu48/4.8.1.1-13+nmu1ubuntu1
After this following command takes long time
/usr/local/bin/wkhtmltopdf -q file:///tmp/wicked_pdf20150609-25535-im12hx.html tmp/wicked_pdf_xxx.pdf

I have removed "bootstrap.css" from PDF generation. Now its working fine

Related

Snowflake on Heroku Via ODBC

Update - I got it working by using Sequel and Ruby-ODBC gems and a different build pack for Heroku (https://elements.heroku.com/buildpacks/daasity/heroku-buildpack-snowflake-odbc)
Had to amend the AptFile line
https://sfc-repo.snowflakecomputing.com/odbc/linux/2.18.3/snowflake-odbc-2.18.3.x86_64.deb
to
https://sfc-repo.snowflakecomputing.com/odbc/linux/latest/snowflake-odbc-2.21.0.x86_64.deb
I am looking for some advice to help resolve an issue I am having trying connect a Rails 5.1 app to a Snowflake database via ODBC on Heroku.
I have tried various methods but keep hitting different issues.
Steps taken so far:
Added heroku-community/apt buildpack
Created AptFile with the below packages:
unixodbc
unixodbc-dev
https://raw.githubusercontent.com/carwow/heroku-buildpack-snowflake-odbc/master/snowflake-odbc.deb
Added odbc_adapter gem (https://github.com/localytics/odbc_adapter)
Modified my database.yml file to include :snowflake connection details.
Created a new class to mirror a table held in Snowflake, added a line to establish_connection to snowflake and a method to test the connection.
When I run this locally, everything works perfectly. When I deploy to Heroku and try to run the same method I get this error:
ODBC::Error: S1000 (-1) [unixODBC][DSI] The error message SFRestRequestFailed could not be found in the en-US locale. Check that /app/.apt/usr/lib/snowflake/odbc/lib/SFMessages_en-US.xml exists.
When I check the file structure on Heroku, I can see that SFMessages_en_US.xml is in a different path.
I tried using isql -v to see if I could get more details but that returns an error:
[28000][unixODBC][DSI] The error message DSIReqSettingNotFound could not be found in the en-US locale. Check that /app/.apt/usr/lib/snowflake/odbc/lib/ODBCMessages_en-US.xml exists.
I've been trying to get this to work but without being able to see the underlying error I am stuck.
Try adding the following (copied from Dockerfile, so you need to change that to match Heroku) before installing SNFLK ODBC drivers:
ENV LANGUAGE=en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
RUN apt-get install locales && locale-gen

How does one make sure that their rails environment on one machine is the same as another?

I have three macs. I have a rails app, that I can run on two of them. On the third, I can create a new rails app and it works fine and some of my other rails apps from the other machines work fine, however the one that I need to have work on the one machine always gives me a message about not being able to find an image:
/Users/woo/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require': dlopen(/Users/woo/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (LoadError)
Referenced from: /usr/local/opt/mysql/lib/libmysqlclient.21.dylib
Reason: image not found - /Users/woo/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle
I have followed suggestions about installing the mysql2 bundle using:
gem install mysql2 -v '0.5.3' -- --with-cflags=\"-I/usr/local/opt/openssl/include\" --with-ldflags=\"-L/usr/local/opt/openssl/lib\"
then bundle install, and it says all is fine. Yet 'rails s' produces that unable to find image message.
I use rbenv to manage versions and on all machines ruby is 2.6.3 and rails is 5.2.4.
What other aspects of the configuration of the app do I need to check to make sure they are the same? I have a script called 'laptop' that I obtained using:
cd ~
curl --remote-name https://raw.githubusercontent.com/monfresh/laptop/master/mac
curl --remote-name https://raw.githubusercontent.com/monfresh/laptop/master/Brewfile
/usr/bin/env bash mac 2>&1 | tee ~/laptop.log
I run this on each machine when I am setting up to install or run a rails app. On the problem machine I do get messages like:
ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
File "/usr/local/Cellar/python#2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
during the laptop run, but at the end it says all modules were installed correctly. I have a feeling that's not really true and may be part of the problem. If so, what is causing this? I'm running OS X 10.14.6 on the machine in question.
I also notice that libssl.1.0.0.dylib is NOT present at the specified location. How do I install this and moreover, how to I make sure that all of these pieces are properly coordinated?
Found it finally! Thank you:
https://rorguide.blogspot.com/2011/07/getting-error-library-not-loaded.html
I had looked at a lot of these and tried the making a soft link to no effect, but this was the first time I found this one!:
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
worked!

Docker on Windows 10 Pro: error file conflict when building new Jekyll site

I am using PowerShell on Windows 10 Pro and have installed Docker version 18.03.1-ce.
I CD into a local directory where I want to edit a set of config files to build my Jekyll webpage. I ran the following command:
docker run -e JEKYLL_NEW=true -p 80:4000 -v ${pwd}:/site bretfisher/jekyll-serve
and the the following message:
NOTE: making new jekyll site!
Conflict: /site exists and is not empty.
Ensure /site is empty or else try again with `--force` to proceed and overwrite any files.
If I use the --force flag inside the call above it tells me unknown flag. Anyone has any idea how to fix this and successfully build a jekyll container linked to my local directory of files to be able to edit and preview on localhost in the browser before pushing it into production?
Pay close attention to the steps in the Jekyll quick start. In step 3, Jekyll creates the directory for your web site. The error message is telling you that there's already an existing site directory with files in it, so Jekyll quits rather than overwrite existing files. If you delete the contents of that directory or move them elsewhere, your jekyll new command can proceed.
You might try picking a different site name, by the way. Jekyll creates its own _site directory where it puts the built HTML files for your site. You're asking for confusion when you have a site/_site directory.

Rails + Passenger: Can't execute shell commands

I've setup Apache + Rails + Passenger and the app loads correctly (for the most part). The application uses Tesseract and GS to convert PDFs into images and then take their text and insert it into the database.
When I test the application using rails s, everything functions normally, but when I try to run some of the functions from the passenger instance, I get the following error in my apache log:
App 14107 stderr: sh: tesseract: command not found
The error occurs for the following code:
%x(gs -dNOPAUSE -dBATCH -sDEVICE=pngalpha -r300 -sOutputFile="page%03d".png #{self.doc.path})
%x(for f in page*.png ; do tesseract $f $f.out; done)
There is nothing in my rails production.log file that indicates any errors.
I'm running CentOS 6 and I built my tesseract using this guide:
https://www.simpleservers.co.uk/clients/whmcs/knowledgebase/600/Install-Tesseract-OCR-libs-from-sources-in-Centos.html
The user that passenger runs as can also run the command tesseract. I checked in its console, but for some reason, passenger can't run it. Do I need to enable it for the apache user somehow?
Thanks
Thanks to shellter for pointing me in the right direction. This is what fixed the issue for me:
Apache couldn't call tesseract, so I had to add it to its path. Based on this answer (How to add path to Apache), I went to /etc/sysconfig/httpd (this is CentOS specific) and added the line:
export PATH=<the path>
To get the path, I just ran this in the console:
env
And took the output for the PATH.

How to use rails bundler behind a proxy network?

I am using ubuntu 12.04. I am trying to run
bundle install
behind the proxy network of my institute.I have correctly setup the apt.conf file and all other downloads from terminal are working fine. I added the following to ~/.bashrc
export HTTP_PROXY=http://user:password#proxy_url:port
alias curl="curl -x http://proxy_url:port/ -U user:password"
alias rvm="rvm --proxy http://user:password#proxy_url:port"
And i added the following to my environment file:
http_proxy="http://user:password#proxy_url:port/"
https_proxy="https://user:password#proxy_url:port/"
ftp_proxy="ftp://user:password#proxy_url:port/"
socks_proxy="socks://user:password#proxy_url:port/"
I also added the following to ~/.gemrc:
http-proxy:http://user:password#proxy_url:port
After making all these changes when i run the bundler using with or without sudo on the terminal i get back the source code of some html page.The code of html page is followed by the line:
Net::HTTPProxyAuthenticationRequired:
Please tell me what to do to make rails run behind the proxy.
This isn't a Rails question per-se, it's a Bundler question.
I would try the following on the command line (either should work):
export HTTP_PROXY=http://user:password#proxy_url:port
export http_proxy=http://user:password#proxy_url:port
Potentially your ~/.bashrc file isn't being executed on login/etc.
I would also change the ~/.gemrc file to: http_proxy=http://user:password#proxy_url:port
Check out the source code in Bundler for any extra information you may need.

Resources