Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support running ./bin/html2haml fully #41

Open
aprescott opened this issue Jan 7, 2014 · 0 comments
Open

Support running ./bin/html2haml fully #41

aprescott opened this issue Jan 7, 2014 · 0 comments

Comments

@aprescott
Copy link

To avoid going through a gem build and gem install ./html2haml-x-y.gem process, it's useful to run ./bin/html2haml and have it automatically use lib/.

First, remove any html2haml gems with gem uninstall. Then try to use ./bin/html2haml.

$ ./bin/html2haml --version

$ touch /tmp/blah.html
$ ./bin/html2haml /tmp/blah.html
/Users/adamprescott/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:114:in `require': cannot load such file -- html2haml/html (LoadError)
    from /Users/adamprescott/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:114:in `require'
    from /private/tmp/html2haml/lib/html2haml.rb:7:in `<top (required)>'
    from /Users/adamprescott/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require'
    from /Users/adamprescott/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require'
    from ./bin/html2haml:3:in `<main>'

If you gem install html2haml (say, version 1.0.1), ./bin/html2haml --version will incorrectly report whatever is for lib/'s version, but will instead try to generate with the version you gem install'd. To see this, note that 1.0.1 has no --ruby19-attributes flag, then:

$ cd /tmp/html2haml # git repo
$ ./bin/html2haml --version
/Users/adamprescott/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:114:in `require': cannot load such file -- html2haml/html (LoadError)
[...]

$ cd
$ gem install html2haml -v '1.0.1'
$ cd /tmp/html2haml # git repo
$ html2haml --version
html2haml 2.0.0.beta.2
$ ./bin/html2haml --trace --ruby19-attributes
/Users/adamprescott/.gem/ruby/2.0.0/gems/html2haml-1.0.1/lib/html2haml/exec.rb:40:in `parse': invalid option: --ruby19-attributes (OptionParser::InvalidOption)
    from /Users/adamprescott/.gem/ruby/2.0.0/gems/html2haml-1.0.1/lib/html2haml/exec.rb:22:in `parse!'
    from ./bin/html2haml:7:in `<main>'

The version is reported as 2.0.0.beta.2 from the repo's value, but it's still using ~/.gem/ruby/2.0.0/gems/html2haml-1.0.1 code.

I think the fix here is to $LOAD_PATH.unshift(...) in bin/html2haml so that it always makes lib/ available to prioritise require "..." calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant