rubyfedoracompass

How to Fix NoMethodError Issue with Ruby Compass (1.0.0 and 1.0.3)


I have a Fedora 38 (6.1.29-1) server with Ruby and the Compass gem installed.

When I try to execute compass -h or perform any compass compiling, I get a NoMethodError (on different lines of different .rb files, but errors nonetheless).

I've looked all around for similar errors and can't seem to find anyone else that experiences this problem.

At first I thought maybe the latest version (1.0.3) of Compass doesn't work on my server, so I also tried 1.0.0 but still get the same error.

I also tried installing the same version(s) and followed the same process on my Windows machine and had no issues when executing the same compass -h and compass compile commands.

Anyone have any idea what is causing this error on my fedora server?

When executing "compass -h" on the command line on the Fedora server...

Current Output:

NoMethodError on line ["144"] of /home/user1/.local/share/gem/ruby/gems/compass-1.0.0/lib/compass/installers/manifest.rb: undefined method `exists?' for File:Class

Expected Output:

Usage: compass help [command]

Description:
  The Compass Stylesheet Authoring Framework helps you
  build and maintain your stylesheets and makes it easy
  for you to use stylesheet libraries provided by others.

Donating:
  Compass is charityware. If you find it useful please make
  a tax deductable donation: http://umdf.org/compass

To get help on a particular command please specify the command.

Primary Commands:
  * clean       - Remove generated files and the sass cache
  * compile     - Compile Sass stylesheets to CSS
  * create      - Create a new compass project
  * init        - Add compass to an existing project
  * watch       - Compile Sass stylesheets to CSS when they change
Other Commands:
  * config      - Generate a configuration file for the provided command line options.
  * extension   - Manage the list of compass extensions on your system
  * frameworks  - List the available frameworks
  * help        - Get help on a compass command or extension
  * imports     - Emit an imports suitable for passing to the sass command-line.
  * install     - Install an extension's pattern into your compass project
  * interactive - Interactively evaluate SassScript
  * sprite      - Generate an import for your sprites.
  * stats       - Report statistics about your stylesheets
  * unpack      - Copy an extension into your extensions folder.
  * validate    - Validate your generated css.
  * version     - Print out version information

Available Frameworks & Patterns:

  * compass
    - compass/ellipsis  - Plugin for cross-browser ellipsis truncated text.
    - compass/extension - Generate a compass extension.
    - compass/project   - The default project layout.

Global Options:
    -r, --require LIBRARY            Require the given ruby LIBRARY before running commands.
                                       This is used to access compass plugins without having a
                                       project configuration file.
    -l, --load FRAMEWORK_DIR         Load the framework or extensions found in the FRAMEWORK directory.
    -L, --load-all FRAMEWORKS_DIR    Load all the frameworks or extensions found in the FRAMEWORKS_DIR directory.
    -I, --import-path IMPORT_PATH    Makes files under the IMPORT_PATH folder findable by Sass's @import directive.
    -q, --quiet                      Quiet mode.
        --trace                      Show a full stacktrace on error
        --force                      Allows compass to overwrite existing files.
        --boring                     Turn off colorized output.
    -?, -h, --help                   Show this message

Solution

  • File.exists? was deprecated for several minor versions and existed until Ruby 2.7. And was finally removed in Ruby 3.0.

    Whereas the last version of the compass gem is more than 8 years old. That means it doesn't work with current version of Ruby anymore.

    You have basically three options:

    1. Downgrade your Ruby version to, for example, 2.7.8. That version is not terrible out-dated, but keep in mind that Ruby 2.7 reached end-of-life, it will not get any security or bug fixes anymore.
    2. Fork the compass gem and fix the usage of File.exists? with File.exist?. This seems to be a quick fix, but given that this gem didn't get any update in the last 8 years, you might discover further compatibility issues or unfixed bugs.
    3. Search for an alternative and replace that gem.