How to output RVM needed download URLs - ruby

I'm trying to install RVM in my workstation.
But in my work's network, the internet is reached via an proxy. This proxy eventually blocks some URLs based in a internal security policy.
I shall to do a request to network administrators about URLs that is being blocked so that they can unblock them for a group of workstations.
This is very important because the policy need to be constantly updated.
What I need is to know which URL the installation is trying to download and that are being blocked.
When I try to install RVM it try to download the archives. The blocked ones arrives corrupted in my computer. I can see messages in the output complaining checksum errors.
e.g.
Installing Ruby from source to: /usr/local/rvm/rubies/ruby-2.0.0-p0, this may take a while depending on your cpu(s)...
ruby-2.0.0-p0 - #downloading ruby-2.0.0-p0, this may take a while depending on your connection...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:06 --:--:-- 0
100 3198 100 3198 0 0 532 0 0:00:06 0:00:06 --:--:-- 532
Downloaded archive checksum did not match, archive was removed!
If you wish to continue with not matching download add '--verify-downloads 2' after the command.
There has been an error fetching the ruby interpreter. Halting the installation.
How can I see the URLs beings downloaded in the RVM install? Probably I'll need this for the gems bundler too.
Thanks in advance.

run:
rvm get head # make sure you use latest rvm code
rvm cleanup archives # clean up all downloaded files so far
rvm install 2.0.0 --debug # install with debug - it will show the downloaded urls

It gives a lot of output, but if you install with the --debug --trace switches then you see everything that RVM is doing, including the URLs that it requests:
$ rvm install 2.0.0 --debug --trace
# ...
# a whole boatload of output
# such as...
+++ 1365712695.744278786 /scripts/functions/utility : __rvm_ruby_package_file() 569 > rvm_ruby_package_file=/ruby-2.0.0-rc2.tar.bz2
+++ 1365712695.856579187 /scripts/functions/utility : __rvm_calculate_remote_file() 583 > __remote_file=https://rvm.io/binaries/ubuntu/12.10/i386/ruby-2.0.0-rc2.tar.bz2
+++ 1365712695.948514158 /scripts/functions/utility : __rvm_remote_server_path_single() 592 > [[ -z https://rvm.io/binaries/ubuntu/12.10/i386/ruby-2.0.0-rc2.tar.bz2 ]]
+++ 1365712696.053688755 /scripts/functions/utility : __rvm_remote_server_path_single() 597 > file_exists_at_url https://rvm.io/binaries/ubuntu/12.10/i386/ruby-2.0.0-rc2.tar.bz2
+++ 1365712696.171561756 /scripts/functions/utility : file_exists_at_url() 714 > [[ -n https://rvm.io/binaries/ubuntu/12.10/i386/ruby-2.0.0-rc2.tar.bz2 ]]
+++ 1365712696.266908604 /scripts/functions/utility : file_exists_at_url() 716 > unset curl
+++ 1365712696.482119274 /scripts/functions/utility : file_exists_at_url() 717 > curl -slkL --max-time 3 --head https://rvm.io/binaries/ubuntu/12.10/i386/ruby-2.0.0-rc2.tar.bz2
+++ 1365712696.512878217 /scripts/functions/utility : file_exists_at_url() 718 > GREP_OPTIONS=
+++ 1365712696.732889205 /scripts/functions/utility : file_exists_at_url() 718 > grep -E 'HTTP/[0-9\.]+ 200 OK'

Related

Ruby 2.3: time_zone.rb:272: warning: circular argument reference - now

As part of upgrading a Dockerfile I'm trying to make a specific gem run that contains guides written some 8+ years ago.
I have found out I have to use Ruby <= 2.3 for it because above that it gives endless syntax errors most probably because of some major changes in 2.4.
I'm installing Ruby 2.3.8 with rvm this way:
# Install libssl-1.0 from 'stretch' repositories (needed for ruby 2.3)
RUN echo "deb http://deb.debian.org/debian/ stretch main contrib non-free" > /etc/apt/sources.list.d/libssl-legacy.lenter code hereist \
&& echo "deb-src http://deb.debian.org/debian stretch main contrib non-free" >> /etc/apt/sources.list.d/libssl-legacy.list \
&& echo "APT::Default-Release "bullseye";" > /etc/apt/apt.conf.d/libssl-legacy \
&& apt update && apt install -y libssl1.0-dev
# Install Ruby 2.3 with RVM (to /usr/local/rvm/rubies/ruby-2.3.8/bin/ruby)
ENV PATH="/usr/local/rvm/bin:$PATH"
ENV rvm_path="/usr/local/rvm"
RUN curl -sSL https://rvm.io/mpapis.asc | gpg2 --import - \
&& curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import - \
&& curl -sSL https://get.rvm.io | bash \
&& rvm install 2.3
A few days ago I managed to make this guide build without a problem, but I can't seem to make it work now. What am I missing?
I get the following error while trying to build the gem with 'guides build':
/usr/local/rvm/gems/ruby-2.3.8/gems/activesupport3.0.20/lib/active_support/values/time_zone.rb:272: warning: circular argument reference - now
It points to this function in time_zone.rb:
# Method for creating new ActiveSupport::TimeWithZone instance in time zone of +self+ from parsed string. Example:
#
# Time.zone = "Hawaii" # => "Hawaii"
# Time.zone.parse('1999-12-31 14:00:00') # => Fri, 31 Dec 1999 14:00:00 HST -10:00
#
# If upper components are missing from the string, they are supplied from TimeZone#now:
#
# Time.zone.now # => Fri, 31 Dec 1999 14:00:00 HST -10:00
# Time.zone.parse('22:30:00') # => Fri, 31 Dec 1999 22:30:00 HST -10:00
def parse(str, now=now)
date_parts = Date._parse(str)
return if date_parts.blank?
time = Time.parse(str, now) rescue DateTime.parse(str)
if date_parts[:offset].nil?
ActiveSupport::TimeWithZone.new(nil, self, time)
else
time.in_time_zone(self)
end
end
ruby -v:
ruby 2.3.8p459 (2018-10-18 revision 65136) [x86_64-linux]
gem -v:
3.3.10
bundler -v:
Bundler version 2.3.10
def parse(str, now=now) <- here is your issue.
you are trying to set now to itself. A circular argument reference means that a variable is looking for itself.
/active_support/values/time_zone.rb:272:: warning: circular argument reference

Download tsv file from link which generates the file upon request, using bash

I need to download .txt files which are generated from links like this one:
https://www.ebi.ac.uk/ena/portal/api/filereport?accession=SRP002480&result=read_run&fields=fastq_ftp&format=tsv&download=true&limit=0
but I need to download it in the bash shell. It works perfectly fine on Firefox, on the shell I tried wget and curl to no avail. I read lots of similar question in Stack Overflow and other pages, tried everything I could find, but couldn't find a solution.
For example:
curl https://www.ebi.ac.uk/ena/portal/api/filereport?accession=SRP002480&result=read_run&fields=fastq_ftp&format=tsv&download=true&limit=0
This is the output, and no file is downloaded:
[1] 1094
[2] 1095
[3] 1096
[4] 1097
[5] 1098
[2] Done result=read_run
[3] Done fields=fastq_ftp
[4]- Done format=tsv
(base) user#DESKTOP-LV4SKHQ:/mnt/c/Users/conog/Desktop/prova$ curl: (6) Could not resolve host: www.ebi.ac.uk
[1]- Exit 6 curl https://www.ebi.ac.uk/ena/portal/api/filereport?accession=SRP002480
[5]+ Done download=true
Another example, after I read a couple of posts here:
curl -O -L https://www.ebi.ac.uk/ena/portal/api/filereport?accession=SRP002480&result=read_run&fields=fastq_ftp&format=tsv&download=true&limit=0
[1] 1056
[2] 1057
[3] 1058
[4] 1059
[5] 1060
[2] Done result=read_run
[3] Done fields=fastq_ftp
[4] Done format=tsv
[5]+ Done download=true
(base) gsoletta#DESKTOP-LV4SKHQ:/mnt/c/Users/conog/Desktop/prova$ % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 49 100 49 0 0 68 0 --:--:-- --:--:-- --:--:-- 67
[1]+ Done
this last one downloads a 49 byte file with no extension, called filereportaccession=SRP002480, with the content: "Required String parameter 'result' is not present".
I'll also add I'm a novice at bash.
What could I do?
Thank you!
It works for me:
$ curl -s 'https://www.ebi.ac.uk/ena/portal/api/filereport?accession=SRP002480&result=read_run&fields=fastq_ftp&format=tsv&download=true&limit=0'
run_accession fastq_ftp
SRR1620013 ftp.sra.ebi.ac.uk/vol1/fastq/SRR162/003/SRR1620013/SRR1620013_1.fastq.gz;ftp.sra.ebi.ac.uk/vol1/fastq/SRR162/003/SRR1620013/SRR1620013_2.fastq.gz
SRR1620014 ftp.sra.ebi.ac.uk/vol1/fastq/SRR162/004/SRR1620014/SRR1620014_1.fastq.gz;ftp.sra.ebi.ac.uk/vol1/fastq/SRR162/004/SRR1620014/SRR1620014_2.fastq.gz
...
$ wget -O filereport.tsv 'https://www.ebi.ac.uk/ena/portal/api/filereport?accession=SRP002480&result=read_run&fields=fastq_ftp&format=tsv&download=true&limit=0'
--2021-11-15 17:51:48-- https://www.ebi.ac.uk/ena/portal/api/filereport?accession=SRP002480&result=read_run&fields=fastq_ftp&format=tsv&download=true&limit=0
Resolving www.ebi.ac.uk (www.ebi.ac.uk)... 193.62.193.80
Connecting to www.ebi.ac.uk (www.ebi.ac.uk)|193.62.193.80|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/plain]
Saving to: ‘filereport.tsv’
...
2021-11-15 17:51:51 (831 KB/s) - ‘filereport.tsv’ saved [675136]
Your problem is that you didn't put quotes around the URL. When you don't quote the URL the &s in it cause each URL parameter to be interpreted as a separate command by bash.

Piping raw code from github to ruby not working?

I am doing some basic piping of some simple raw code from github to terminal as shown here i.e.
curl https://raw.github.com/leachim6/hello-world/master/r/ruby.rb | ruby
When I try it, it doesn't produce "Hello World", but instead I just see
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
use
curl -sSL https://raw.github.com/leachim6/hello-world/master/r/ruby.rb | ruby
this should work
Update to explain
this URL is redirecting to
https://raw.githubusercontent.com/leachim6/hello-world/master/r/ruby.rb
so -L option was required to follow the redirection (-L, --location)
this option will make curl redo the request on the new place
sS to hide the progress bar and show errors if happened
to debug curl request you can use -v option which will make you see exactly what is happening

How do I download a file to a newly created directory with curl on OS X?

I am trying to download my Heroku backups to a folder.
Downloading to the current folder like this works:
curl -o latest.dump `heroku pg:backups public-url`
But when I tried adding a folders path to latest.dump it looks like this:
$ curl -o /db-bkups/latest.dump `heroku pg:backups public-url`
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 44318 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0Warning: Failed to create the file
Warning: /db-bkups/latest.dump: No such file
Warning: or directory
36 44318 36 16384 0 0 9626 0 0:00:04 0:00:01 0:00:03 9626
curl: (23) Failed writing body (0 != 16384)
Ideally, I would like it be saved and downloaded like this:
/db-bkups/nov-1-2016/timestamp-db.dump
Where the folder nov-1-2016 is created dynamically when the cron is run, and the filename is the timestamp when the bkup was run.
You could try using the --create-dirs argument which was added in curl 7.10.3:
Here is an example that will create the directory hierarchy, (if it doesn't already exist), and will name the subdirectory you require renamed with the output of the datecommand:
curl -o /db-bkups/$(date +"%b-%d-%Y")/timestamp-db.dump --create-dirs http://www.w3schools.com/xml/simple.xml
The result is a file stored in a directory like so /db-bkups/Nov-04-2016/timestamp-db.dump.

executing .sh file - "./gradlew no such file or directory" and misc errors

I'm trying to run a .sh file on Windows. More exactly I'm trying to run the build scripts in the following GitHub repo: https://github.com/facebook/facebook-sdk-for-unity.
But I'm extremely novice when it comes to .sh files. And came as far as executing the file by writing the following in "Git Shell": sh ./setup.sh.
I'm unsure which errors is actually "errors", but I've bolded what I think is the important issue. It's also worth mentioning that I've downloaded Gradle 3.1 and added it to my path variable. gradle -v does work (in cmd), but gradlew as a command does not. What am I missing? I feel stupid. :/
I get the following output/errors:
D:\GitHub\facebook-sdk-for-unity [tmp-test-bashscripts]> sh .\scripts\setup.sh
/d/GitHub/facebook-sdk-for-unity/scripts/local.properties: line 1: sdk.dir=D:\Android\android-sdk\sdk: No such file or directory
sed: can't read /FacebookSdkVersion.cs: No such file or directory
.\scripts\setup.sh: line 25: buildAndCopyCore: command not found
.\scripts\setup.sh: line 26: buildAndCopyPlatformDLLs: command not found
/d/GitHub/facebook-sdk-for-unity/scripts/local.properties: line 1: sdk.dir=D:\Android\android-sdk\sdk: No such file or directory
sed: can't read /FacebookSdkVersion.cs: No such file or directory
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 75.1M 100 75.1M 0 0 359k 0 0:03:33 0:03:33 --:--:-- 372k
**/d/GitHub/facebook-sdk-for-unity/scripts/local.properties: line 1: sdk.dir=D:\Android\android-sdk\sdk: No such file or directory**
sed: can't read /FacebookSdkVersion.cs: No such file or directory
\033[0;36mStarting build \033[0m
\033[0;36mStep 1 - Cleaning wrapper libs folder \033[0m
/d/GitHub/facebook-sdk-for-unity/facebook-android-wrapper/libs /d/GitHub/facebook-sdk-for-unity
find: warning: you have specified the -maxdepth option after a non-option argument !, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it). Please specify options before other arguments.
/d/GitHub/facebook-sdk-for-unity
\033[0;36mStep 2 - Get depenancies for android wrapper \033[0m
\033[0;36mStep 2.1.0 - Download bolts-android-1.4.0.jar \033[0m
\033[0;36mbolts-android-1.4.0.jar already exists. Skipping download. \033[0m
\033[0;36mStep 2.1.1 - Download bolts-tasks-1.4.0.jar \033[0m
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 178 100 178 0 0 546 0 --:--:-- --:--:-- --:--:-- 642
100 190 100 190 0 0 212 0 --:--:-- --:--:-- --:--:-- 690
100 38092 100 38092 0 0 28892 0 0:00:01 0:00:01 --:--:-- 28892
\033[0;36mStep 2.1.2 - Download bolts-applinks-1.4.0.jar \033[0m
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 178 100 178 0 0 650 0 --:--:-- --:--:-- --:--:-- 661
100 196 100 196 0 0 233 0 --:--:-- --:--:-- --:--:-- 233
100 25020 100 25020 0 0 20337 0 0:00:01 0:00:01 --:--:-- 228k
\033[0;36mStep 2.2 - Download facebook-android-sdk-4.14.0.aar \033[0m
\033[0;36mfacebook-android-sdk-4.14.0.aar already exists. Skipping download \033[0m
\033[0;36mStep 2.3 - Coping support lib \033[0m
\033[0;36mStep 3 - Build android wrapper \033[0m
/d/GitHub/facebook-sdk-for-unity/facebook-android-wrapper /d/GitHub/facebook-sdk-for-unity
**/d/GitHub/facebook-sdk-for-unity/scripts/setup_android_unity_plugin.sh: line 118: ./gradlew: No such file or directory**
\033[0;31mFATAL: Failed to perform gradle clean \033[0m
\033[0;31mFATAL: Failed to build the android sdk plugin \033[0m
It looks like you are running sh .\scripts\setup.sh in a cmd or Git CMD window. Open a Git Bash window instead. It's important to see "Bash" in its name. In that shell, go to the project directory with the cd command, and run sh ./setup.sh as it was written in the documentation.

Resources