30 Jan 2013, 15:57
Leo-1_pragsmall

Leonel Santos (11 posts)

This is very frustrating. Seems like GLI has been updated and a lot of things are not as expected if you’re reading the book. It might be obvious to people that already know how GLI works but for us newbies is not that simple. Maybe it would be a good idea to include the version of GLI the book is using. that way everything will work as expected.

I have several questions regarding the above but I’m going to post them in different posts. First of all, how can we avoid having to use bundle exec? The samples of the book don’t use it. I was fine using bundle exec but the deeper you go into the book, there are other things in the command line I had to tweak until is now very different from the book.

So how can we not need to use bundle exec to run the todo app?

30 Jan 2013, 22:29
Dmfcb_pragsmall

David Copeland (98 posts)

The book uses the latest version of the 1.x line of GLI, which you can install via @gem install gli -v 1.6.0@ or via @add_dependency(“gli”,”1.6.0”)@ in your gemspec or @gem ‘gli’, ‘1.6.0’@ in your Gemfile, depending on how you have things set up. Note that if you aren’t using bundler, you should uninstall the later version of GLI.

That being said, all the examples should work with GLI2 save for the following changes: http://forums.pragprog.com/forums/200/topics/10975 Everything in the book about GLI should still work with GLI2 and, if it doesn’t, please file a github issue: https://github.com/davetron5000/gli/issues?sort=updated&state=closed

As to the use of bundle exec, I had thought the book was consistent with this - page 144 outlines why this is necessary.

When the user installs your app, she will not need to use bundle exec. If you wish to avoid it during development, you will need to either set @RUBYLIB@ as described on page 144 of the book, or you’ll need to hack the load path at the top of your executable, like so:

#!/usr/bin/env ruby


$: << File.join(File.dirname(__FILE__),'..','lib')

require 'gli'
require 'todo'
# etc

Please let me know what other problems you are having - as I said I thought things worked, but it’s entirely possible I’m missing something and would definitely like to fix it.

31 Jan 2013, 22:09
Leo-1_pragsmall

Leonel Santos (11 posts)

Cool man, thanks!

Don’t misunderstand me. I love your book, I’m learning tons. It’s just that I wanted to make consistent progress, like one chapter a day, but I keep on hitting bumps and having to re-read portions or search for solutions. I understand this is normal in programming, things don’t always work as expected. I just think a few things have to be ironed out, for example, I got very confused about using todo then to-do and then todo again. I thought todo.rb and to-do.rb were both necessary but it turns out I only needed bin/todo. I hadn’t checked the errata page, but once I did, lot of things made more sense.

About not using bundle exec to run the commands I read in a post in stackoverflow that sometimes it’s not as secure because then linux can try to run other files as executables too. So I’m going to keep the bundle exec for now and later come back to it and make more research.

I think it’s awesome that the author of the book personally addresses issues about the book.

I can’t wait to read and follow the exercises of the whole book and then get ideas to write my very own command line application. Your book is great man!

01 Feb 2013, 21:21
Dmfcb_pragsmall

David Copeland (98 posts)

Yeah, it’s hard to make sure that the examples and code I’ve been working with for almost a year make sense to someone new to the material, so thanks for all the feedback (and thanks for buying the book! :)

I monitor the forum, so please post more questions if you have them.

  You must be logged in to comment