How to setup Rails System Test - ruby-on-rails

I am currently trying to set up some system testing for my rails web application (using Rails version 7.0.3.1)
When running rails test:system to run a single system test I had written, I am getting the below setup-related error
Command '/usr/bin/chromium-browser' requires the chromium snap to be installed.
Please install it with:
snap install chromium
.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/webdrivers-5.0.0/lib/webdrivers/system.rb:190:in `call': Failed to make system call: ["/usr/bin/chromium-browser", "--product-version"] (RuntimeError)
And then, when I try to run
snap install chromium
as suggested by the error I am getting back, I then run into the following error
error: cannot communicate with server: Post http://localhost/v2/snaps/chromium: dial unix /run/snapd.socket: connect: no such file or directory
I am lost as to how to move forward with this issue, which is preventing me from being able to run any system tests. There also seem to not be too many related issues online currently that applied to this case. Any help/ suggestions on where to look to further troubleshoot this error would be greatly appreciated.

Try to install it from the Google, depends on your ubuntu versions:
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
apt install ./google-chrome-stable_current_amd64.deb

Related

./prereqs-ubuntu.sh Error: Ubuntu focal is not supported

I'm trying to use composer and for the same I'm using the below command for installation.
curl -O https://hyperledger.github.io/composer/latest/prereqs-ubuntu.sh
chmod u+x prereqs-ubuntu.sh
These above commands successfully executed.
But when I executed this command (./prereqs-ubuntu.sh) then I'm getting below error
Terminal Throws Error ///Ubuntu focal is not supported
Please help
Hyperledger Composer Installation
I also find this kind of error during Hyperledger Composer installation this problem mainly depends on the Ubuntu version.
Steps to overcome this problem.
upgrade ubuntu version as per your ubuntu versoin please follow:
https://www.fosslinux.com/38303/how-to-upgrade-to-ubuntu-20-04-lts-focal-fossa.htm
open file prereqs-ubuntu.sh with your compatible editor
update line:
#Array of supported versions
declare -a versions=('trusty' 'xenial' 'yakkety', 'bionic');
with
# Array of supported versions
declare -a versions=('trusty' 'xenial' 'yakkety', 'bionic', 'focal');
After saving this file
Run command: ./prereqs-ubuntu.sh
I hope this problem will resolve if anything please feel free to write.

Composer Docker image won't run at all

I'm attempting to learn how to create a Laravel Docker image by following a tutorial on DigitalOcean using WSL. Following the instructions on the Docker Hub page, however, yields an error:
❯ docker run --rm --interactive --tty -v $(pwd):/app composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 94 installs, 0 updates, 0 removals
- Installing voku/portable-ascii (1.4.10): Failed to download voku/portable-ascii from dist: Could not delete /app/vendor/voku/portable-ascii/src/voku/helper:
Now trying to download from source
- Installing voku/portable-ascii (1.4.10):
[RuntimeException]
Could not delete /app/vendor/voku/portable-ascii/src/voku/helper:
install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...
How can I diagnose what I'm doing wrong?
It turns out that the underlying problem had nothing to do with Docker at all. In fact, Composer was trying to tell me what the problem was all along, but I dismissed it as just a symptom of a deeper issue:
[RuntimeException]
Could not delete /app/vendor/voku/portable-ascii/src/voku/helper:
This message was the crux of it all. I noticed that the directory mentioned, [...]/helper, was empty, so I tried to remove it by hand with rmdir. Instead, I got a No such file or directory error message. I attempted many other was to kill this directory, the entire project directory with rm -rf ~/laravel-app from the home folder, etc. Nothing worked.
Some digging around on the internet suggested that it could be an NTFS corruption if I was running into this issue on Windows. Since I am, indeed, attempting this on WSL (Windows Subsystem for Linux), I gave their suggested fix a try: running chkdsk /F in CMD/PowerShell. A reboot was necessary to complete this task, but after getting everything back up and trying those first few tutorial steps again, I was able to get composer to install the Laravel dependencies without a hitch.
Bottom line: If you run into this sort of issue on WSL, please try running chkdsk /F and reboot. You might just have a similar file system corruption.
We have two possibilities for this error:
1 - You did not execute the command inside the directory :
cd ~/laravel-app
2 - I'm sure there is an internal proxy that is blocking the download of packages.

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!

OpenSuse - Can't install Rails: File not found on medium

I'm trying to set up a Ruby on Rails environment within OpenSuse, but I've encountered a problem. When running sudo zypper install rubygem-railties-3_2 all I get is File '/repodata/repomd.xml' not found on medium 'http://download.opensuse.org/repositories/Banshee/12.1/'. So something seems to be wrong at their side.
Is there anyone who as a workaround for, or more info about, this problem?
When running the command $ sudo zypper up I was receiving a similar error:
File ... not found on medium http:// ...
Detailed error:
File './x86_64/libxkbcommon0-0.7.2-48.2.x86_64.rpm' not found on medium 'http://download.opensuse.org/repositories/KDE:/Qt5/openSUSE_Leap_42.3/'
The solution which worked for me was to run $ sudo zypper ref before running $ sudo zypper up
Obviously, you have setup an additional repository for Banshee for a very old opensuse version. Opensuse only keeps its repositories alive for the last two two releases to the current release. For this reason, you get this error. You can disable or remove the repositorium to resolve the error.
In order to install packages that are not part of the currently configured repositories, it is the easiest to use the one-click install available at https://software.opensuse.org/search .

Resources