Install Nokogiri 1.8.0 In Termux

0 views
Skip to first unread message

Brook Mithani

unread,
Aug 5, 2024, 7:38:21 AM8/5/24
to cordualicall
Native gems" contain pre-compiled libraries for a specific machine architecture. On supported platforms, this removes the need for compiling the C extension and the packaged libraries, or to install system dependencies. This results in much faster installation and more reliable installation, which as you probably know have historically been challenging topics for Nokogiri users.

If you're on a supported platform, either gem install or bundle install should install a native gem without any additional action on your part. This installation should only take a few seconds, and your output should look something like:


If you're using Bundler >= 2.2, check that your lockfile knows about your platform(s). For example, if you develop on macOS and deploy to Linux you will need to run these commands in your development environment:


I can imagine some folks might have trust issues; if this is you, please let us know in a comment at RFC: Increase the level of trust in released gem files Issue #2013 sparklemotion/nokogiri. What can we do to increase that trust? (I can imagine providing a chain of custody including public build logs with cryptographic hashes of artifacts, but I'd like to hear from real users.)


The Nokogiri maintainers strongly urge you to use a native gem if at all possible. We expect it will be a much better experience for you and allow us to focus our efforts on improving functionality rather than diagnosing installation issues.


Nokogiri will refuse to build against older, unsupported versions of libxml2 and libxslt, and there may be some behavioral changes when using older versions. If you have installed libxml2 or libxslt to a custom location, please jump to the next section, Installing With Custom / Non-Standard Libraries.


If you don't see your operating system or distro listed below, then no additional setup is required beyond Appendix A: The Compiler Toolchain. Just run gem install nokogiri --platform=ruby -- --use-system-libraries. Or, if you're using bundler, bundle config build.nokogiri --use-system-libraries.


When optimizing the size of an Alpine image, the runtime libraries must be permanently added. Additionally, adding and removing development tooling can be chained with gem installation to ensure a small layer.


This error can occur when a version of Nokogiri installed for a different version of Ruby is used by an unsupported version of Ruby. For example, if Nokogiri v1.12.5-x86_64-linux installed by Ruby 3.0 is then used by Ruby 3.1, you'll see this error (note that nokogiri v1.12.5 native gems do not support Ruby 3.1).


A common workflow is for a team to develop on a Mac but deploy to production on Linux. This workflow depends on Bundler caching an appropriate gem file in vendor/cache. Unfortunately, in this situation Bundler's default behavior is to cache only gems for the development system and not the production system, leading to an error at deploy time.


Bundler 2.2 and later has great multiplatform support and allows you to cache gems for multiple platforms. You can run commands like these to cause Bundler to fetch and cache gems for all the named platforms:


If you can't upgrade to Bundler >= 2.2, you can force older versions to always use the ruby platform, which supports all platforms, but applies to all gems and comes with the installation challenges mentioned earlier in this guide.


Starting in v1.13.2, the source archive used for libxml2 and libxslt is compressed with xz (previous versions were compressed with gzip. As a result, when compiling from source, your system will need to have xz installed in order to extract the source code for these libraries.


When using Homebrew, there are several libraries that use a formula called xz (including the_silver_searcher and imagemagick), which by default install a version of liblzma that is incompatible with most Ruby builds. (Homebrew installs only the 64-bit version of the library, but most Ruby builds are universal.) This can be fixed in a couple of ways:


A good way to tell if you've got your basic Ruby C extension compiler toolchain installed correctly is to try installing the bcrypt gem which has a smaller, self-contained C extension. If you can gem install bcrypt, you're all set!


One of the most common causes of bundle install errors is a missing or outdated version of the RubyGems package manager. RubyGems is a package manager for the Ruby programming language that is used to manage the installation and updating of Ruby libraries, also known as gems. If the version of RubyGems is outdated or missing, it may lead to errors when running bundle install.


Another common cause of bundle install errors is a missing or outdated version of the Bundler gem. Bundler is a gem that is used to manage dependencies in a Ruby project. If the version of Bundler is outdated or missing, it may lead to errors when running bundle install.


Another cause of bundle install errors is conflicting versions of a gem in the Gemfile.lock file. A Gemfile.lock file is a file that stores the exact versions of all the gems that are used in a project. If there are conflicting versions of a gem in this file, it may lead to errors when running bundle install.


A similar cause is conflicting dependencies between two or more gems in a project. If two or more gems in a project depend on different versions of another gem, it may lead to errors when running bundle install.


In this example, the error message is indicating that the current version of Bundler (2.2.5) is incompatible with the version of the Rails gem specified in the Gemfile (5.2.1). The error message suggests running gem install bundler to update Bundler to resolve the problem.


In this example, the error message is indicating that the current version of Ruby installed is not compatible with the version required by the nokogiri gem (2.3), and the error message suggests that we should upgrade our Ruby version to a version greater than 2.3.


Managing errors and exceptions in your code is challenging. It can make deploying production code an unnerving experience. Being able to track, analyze, and manage errors in real-time can help you proceed with more confidence. Rollbar automates error monitoring and triaging, making fixing Ruby errors easier than ever. Try it today!


Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.


The error is saying that your current nokogiri install needs a higher version of Ruby. So, either install a different nokogiri or have multiple installs of Ruby. If you're on Mac/Linux, rvm can help you with that - on Windows, try something like Uru.


Can you see the Gemfile and Gemfile.lock files? In those, you want to set the Nokogiri versions. You're currently trying to install 1.10.4. If you change that version to 1.8.2, that is compatible with Ruby 2.2.x


Where are you up to with the course - have you created a new Rails app yet? If not, then I was wrong to suggest looking at the Gemfile; apologies. If you have created a Rails app, the gem will be in the app's Gemfile.lock; not the generic Rails ones that you've posted.


Essentially, the Rails version you are installing is using a later version of Nokogiri than your Ruby version can cope with. What version of Rail are you installing and what method are you using to do that?


Best thing to do here is to install the later version of Ruby, i.e. 2.3 or higher, but not higher than 2.6. You might need to remove the installation of 2.2.5 as switching between Ruby versions on Windows (I found) is a nightmare. The alternative is to try an older version of Nokogiri - I'm not sure if you can run gem install nokogiri 1.8.2, for example.


2017-04-26 07:23:20gitter1(bitcoinmeetups) @frumpylava Okay I went down to the crontabs directory and manually edited a file with my user ID as name. It actually worked. Glad to see it working, because I have tried making crontabs a bunch of times and it never seems to work well. Thanks for the advice and happy coding : D


2017-04-26 12:35:40frumpylavalol, my bank has an sms service that I can query my balance with. I wrote a script that automatically queries this every hour and displays my current balance in my tmux status bar. the termux-api is pretty great.


2017-04-26 21:18:44gitter1(bitcoinmeetups) Good morning. So I want to start crond automatically at launch through .bashrc. Where is that file on Termux? I made a whereis search and found three different directories


2017-04-28 05:19:54BrainDamagesymlinking the individual files also has the advantage of not having the runtime files polluting the system package dir, damn having runsv writing runtime files in the config dir is such an annoying choice


2017-04-28 06:10:42gitter1(bitcoinmeetups) @frumpylava The command that runs directly in the crontab gets repeated about ten times or so. The command which is run indirectly in a .sh file which is called from the crontab seems to give the correct result.


2017-04-28 22:45:30gitter1(mklein994) live_the_dream: I just tried compiling ncmpcpp with your boost package and it failed: configure: error: cannot find the flags to link with Boost locale. Is that an option missing from the build.sh for boost?


2017-04-29 02:48:46gitter1(bitcoinmeetups) Is there a way to access the Termux home directory on the internal storage without using a root file explorer? ES file explorer cannot browse to this part of storage as far as I know.


2017-05-14 13:34:27gitter1(mklein994) Yeah. For some reason I had experienced the same thing. I just rmed it and recreated it and it worked. Maybe it has to have a different timestamp to allow the update? I dunno.


2017-05-16 14:04:55gitter1(sdrausty) xargs moves the pipe around to the piped command. In this case grep takes the arguments of find and prints every occurrence and the line in with the text search was found.

3a8082e126
Reply all
Reply to author
Forward
0 new messages