jekyll / jekyll-import

:inbox_tray: The "jekyll import" command for importing from various blogs to Jekyll format.
https://import.jekyllrb.com
MIT License
515 stars 316 forks source link

Import blogger command fails with `undefined method 'decode' for URI:Module (NoMethodError)` #509

Closed sproctor closed 1 year ago

sproctor commented 1 year ago

Command:

$ jekyll import blogger --source blog-02-19-2023.xml --no-blogger-info --replace-internal-link --comments 
jekyll 4.3.2 | Error:  Whoops, we can't understand your command.
jekyll 4.3.2 | Error:  invalid option: --no-blogger-info
jekyll 4.3.2 | Error:  Run your command again with the --help switch to see available options.
/home/sproctor/code/php-calendar.org/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/program.rb:33:in `go': invalid option: --no-blogger-info (OptionParser::InvalidOption)
    from /home/sproctor/code/php-calendar.org/vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
    from /home/sproctor/code/php-calendar.org/vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/exe/jekyll:15:in `<top (required)>'
    from /home/sproctor/.rvm/gems/ruby-3.2.0/bin/jekyll:25:in `load'
    from /home/sproctor/.rvm/gems/ruby-3.2.0/bin/jekyll:25:in `<main>'
    from /home/sproctor/.rvm/gems/ruby-3.2.0/bin/ruby_executable_hooks:22:in `eval'
    from /home/sproctor/.rvm/gems/ruby-3.2.0/bin/ruby_executable_hooks:22:in `<main>'
sproctor commented 1 year ago

It's a bit more complicated. Removing the command line options reveals that it needs jekyll-import. After installing that, I still get the message:

You must install the 'jekyll-import' gem version > 0 to use the 'jekyll import' command.

I have jekyll-import 0.21.0 installed.

ashmaroli commented 1 year ago

Does jekyll --help show import under subcommands?

sproctor commented 1 year ago
jekyll --help
jekyll 4.3.2 -- Jekyll is a blog-aware, static site generator in Ruby

Usage:

  jekyll <subcommand> [options]

Options:
        -s, --source [DIR]  Source directory (defaults to ./)
        -d, --destination [DIR]  Destination directory (defaults to ./_site)
            --safe         Safe mode (defaults to false)
        -p, --plugins PLUGINS_DIR1[,PLUGINS_DIR2[,...]]  Plugins directory (defaults to ./_plugins)
            --layouts DIR  Layouts directory (defaults to ./_layouts)
            --profile      Generate a Liquid rendering profile
        -h, --help         Show this message
        -v, --version      Print the name and version
        -t, --trace        Show the full backtrace when an error occurs

Subcommands:
  compose               
  docs                  
  import                
  build, b              Build your site
  clean                 Clean the site (removes site output and metadata file) without building.
  doctor, hyde          Search site and print specific deprecation warnings
  help                  Show the help message, optionally for a given subcommand.
  new                   Creates a new Jekyll site scaffold in PATH
  new-theme             Creates a new Jekyll theme scaffold
  serve, server, s      Serve your site locally
sproctor commented 1 year ago

I'm not 100% comfortable with Ruby. I'm using RVM. It's possible that something is going wrong because of that.

ashmaroli commented 1 year ago

I see import along with compose and docs in the list. So, you have a detectable version installed at minimum. Now, what is the output from running jekyll import --help or jekyll help import?

sproctor commented 1 year ago
$ jekyll import --help
jekyll import

Usage:

  jekyll import

Options:

        -s, --source [DIR]  Source directory (defaults to ./)
        -d, --destination [DIR]  Destination directory (defaults to ./_site)
            --safe         Safe mode (defaults to false)
        -p, --plugins PLUGINS_DIR1[,PLUGINS_DIR2[,...]]  Plugins directory (defaults to ./_plugins)
            --layouts DIR  Layouts directory (defaults to ./_layouts)
            --profile      Generate a Liquid rendering profile
        -h, --help         Show this message
        -v, --version      Print the name and version
        -t, --trace        Show the full backtrace when an error occurs
ashmaroli commented 1 year ago

Hmm.. that's strange. I would like to see the output of running gem list jekyll

sproctor commented 1 year ago
$ gem list jekyll

*** LOCAL GEMS ***

jekyll (4.3.2)
jekyll-feed (0.17.0)
jekyll-import (0.21.0)
jekyll-sass-converter (3.0.0)
jekyll-seo-tag (2.8.0)
jekyll-watch (2.2.1)
sproctor commented 1 year ago

In case it's interesting:

$ which jekyll
/home/sproctor/.rvm/gems/ruby-3.2.0/bin/jekyll
$ which gem
gem () {
    \typeset result
    (
        \typeset rvmrc
        rvm_rvmrc_files=("/etc/rvmrc" "$HOME/.rvmrc") 
        if [[ -n "${rvm_prefix:-}" ]] && ! [[ "$HOME/.rvmrc" -ef "${rvm_prefix}/.rvmrc" ]]
        then
            rvm_rvmrc_files+=("${rvm_prefix}/.rvmrc") 
        fi
        for rvmrc in "${rvm_rvmrc_files[@]}"
        do
            [[ -s "${rvmrc}" ]] && source "${rvmrc}" || true
        done
        unset rvm_rvmrc_files
        command gem "$@"
    ) || result=$? 
    hash -r
    return ${result:-0}
}
ashmaroli commented 1 year ago

I need to test if something weird happens with Ruby 3.2.x... Your jekyll import --help is incomplete. Either it didn't install properly or something else is interfering.. Your gem-list doesn't show jekyll-compose plugin to be installed. Yet, jekyll help lists compose as available subcommand..

sproctor commented 1 year ago

RVM is weird. It seems to do some really weird things. I'm sorry that I'm mixing a few different strategies at once here. I installed ruby 3.1, and put the dependencies into the Gemfile. This seems to have at least gotten me past the above issue. If you still want to investigate that one, I'm happy to help, but I've found a way around it. Unfortunately, I'm still getting an error, but it looks much more obvious:

$ bundle exec jekyll import blogger --source blog-02-19-2023.xml --no-blogger-info --replace-internal-link --comments
jekyll 4.3.2 | Error:  undefined method `decode' for URI:Module

                file_name = URI.decode("#{post_data[:filename]}.html")
                               ^^^^^^^
/home/sproctor/code/php-calendar.org/vendor/bundle/ruby/3.1.0/gems/jekyll-import-0.21.0/lib/jekyll-import/importers/blogger.rb:197:in `tag_end': undefined method `decode' for URI:Module (NoMethodError)

                file_name = URI.decode("#{post_data[:filename]}.html")
                               ^^^^^^^
    from /home/sproctor/code/php-calendar.org/vendor/bundle/ruby/3.1.0/gems/rexml-3.2.5/lib/rexml/parsers/streamparser.rb:36:in `parse'
    from /home/sproctor/code/php-calendar.org/vendor/bundle/ruby/3.1.0/gems/jekyll-import-0.21.0/lib/jekyll-import/importers/blogger.rb:47:in `block in process'
    from /home/sproctor/code/php-calendar.org/vendor/bundle/ruby/3.1.0/gems/jekyll-import-0.21.0/lib/jekyll-import/importers/blogger.rb:45:in `open'
    from /home/sproctor/code/php-calendar.org/vendor/bundle/ruby/3.1.0/gems/jekyll-import-0.21.0/lib/jekyll-import/importers/blogger.rb:45:in `process'
    from /home/sproctor/code/php-calendar.org/vendor/bundle/ruby/3.1.0/gems/jekyll-import-0.21.0/lib/jekyll-import/importer.rb:25:in `run'
    from /home/sproctor/code/php-calendar.org/vendor/bundle/ruby/3.1.0/gems/jekyll-import-0.21.0/lib/jekyll-import.rb:30:in `block (3 levels) in add_importer_commands'
    from /home/sproctor/code/php-calendar.org/vendor/bundle/ruby/3.1.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
    from /home/sproctor/code/php-calendar.org/vendor/bundle/ruby/3.1.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
    from /home/sproctor/code/php-calendar.org/vendor/bundle/ruby/3.1.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
    from /home/sproctor/code/php-calendar.org/vendor/bundle/ruby/3.1.0/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
    from /home/sproctor/code/php-calendar.org/vendor/bundle/ruby/3.1.0/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
    from /home/sproctor/code/php-calendar.org/vendor/bundle/ruby/3.1.0/gems/jekyll-4.3.2/exe/jekyll:15:in `<top (required)>'
    from /home/sproctor/code/php-calendar.org/vendor/bundle/ruby/3.1.0/bin/jekyll:25:in `load'
    from /home/sproctor/code/php-calendar.org/vendor/bundle/ruby/3.1.0/bin/jekyll:25:in `<main>'
    from /home/sproctor/.rvm/gems/ruby-3.1.3/bin/ruby_executable_hooks:22:in `eval'
    from /home/sproctor/.rvm/gems/ruby-3.1.3/bin/ruby_executable_hooks:22:in `<main>'