bradyaturner / lights

A Ruby library & CLI for interacting with Philips Hue
MIT License
37 stars 7 forks source link

We broke the CLI #27

Closed bradyaturner closed 10 years ago

bradyaturner commented 10 years ago

Changes do development code are being picked up by the installed executable:

Bradys-MacBook-Pro:rubyhue bradyaturner$ git status
# On branch bat-groups
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   lib/rubyhue.rb
#
no changes added to commit (use "git add" and/or "git commit -a")
Bradys-MacBook-Pro:rubyhue bradyaturner$ ./bin/hue list
TEST
[1] Hue Lamp 1
TEST
[2] Hue Lamp 2
TEST
[3] Hue Lamp 3
TEST
[4] Hue Lamp 4
TEST
[5] BT Lamp
Bradys-MacBook-Pro:rubyhue bradyaturner$ hue list
TEST
[1] Hue Lamp 1
TEST
[2] Hue Lamp 2
TEST
[3] Hue Lamp 3
TEST
[4] Hue Lamp 4
TEST
[5] BT Lamp

And that's if you're running in the project directory. Anywhere else, and it just doesn't work:

bradysmacbookpro:~ bradyaturner$ hue list
/Users/bradyaturner/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/shared_helpers.rb:22:in `default_gemfile': Could not locate Gemfile (Bundler::GemfileNotFound)
    from /Users/bradyaturner/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler.rb:231:in `default_gemfile'
    from /Users/bradyaturner/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler.rb:177:in `root'
    from /Users/bradyaturner/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler.rb:99:in `bundle_path'
    from /Users/bradyaturner/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler.rb:363:in `configure_gem_home_and_path'
    from /Users/bradyaturner/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler.rb:90:in `configure'
    from /Users/bradyaturner/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler.rb:146:in `definition'
    from /Users/bradyaturner/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler.rb:116:in `setup'
    from /Users/bradyaturner/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
    from /Users/bradyaturner/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/rubyhue-0.0.4/bin/hue:5:in `<top (required)>'
    from /Users/bradyaturner/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/bin/hue:23:in `load'
    from /Users/bradyaturner/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/bin/hue:23:in `<main>'
    from /Users/bradyaturner/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/bin/ruby_noexec_wrapper:14:in `eval'
    from /Users/bradyaturner/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/bin/ruby_noexec_wrapper:14:in `<main>'

I went back and checked out commit 8c9ea90795f0968dc2173c7d9fb71faea410cfac, before we merged #24, and now the executable works outside the project directory, but the behavior is weird:

Bradys-MacBook-Pro:rubyhue bradyaturner$ git diff
diff --git a/lib/rubyhue.rb b/lib/rubyhue.rb
index 11c3581..a17a36a 100755
--- a/lib/rubyhue.rb
+++ b/lib/rubyhue.rb
@@ -65,6 +65,7 @@ class Hue
   end

   def request_bulb_info( id )
+    puts "TEST"
     response = hue_get "lights/#{id}"
     HueBulb.new(id,response)
   end
Bradys-MacBook-Pro:rubyhue bradyaturner$ hue list
TEST
[1] Hue Lamp 1
TEST
[2] Hue Lamp 2
TEST
[3] Hue Lamp 3
TEST
[4] Hue Lamp 4
TEST
[5] BT Lamp
Bradys-MacBook-Pro:rubyhue bradyaturner$ ./bin/hue list
[1] Hue Lamp 1
[2] Hue Lamp 2
[3] Hue Lamp 3
[4] Hue Lamp 4
[5] BT Lamp

In that output, the installed gem is picking up the change to the dev code, but the dev CLI isn't! WTF!

bradyaturner commented 10 years ago

@bobbyduhbrain

bradyaturner commented 10 years ago

Update:

I'm not sure what happened last night, but the output after I reverted it isn't as confusing:

bradysmacbookpro:rubyhue bradyaturner$ git diff
diff --git a/lib/rubyhue.rb b/lib/rubyhue.rb
index 11c3581..a17a36a 100755
--- a/lib/rubyhue.rb
+++ b/lib/rubyhue.rb
@@ -65,6 +65,7 @@ class Hue
   end

   def request_bulb_info( id )
+    puts "TEST"
     response = hue_get "lights/#{id}"
     HueBulb.new(id,response)
   end
bradysmacbookpro:rubyhue bradyaturner$ ./bin/hue list
TEST
[1] Hue Lamp 1
TEST
[2] Hue Lamp 2
TEST
[3] Hue Lamp 3
TEST
[4] Hue Lamp 4
TEST
[5] BT Lamp
bradysmacbookpro:rubyhue bradyaturner$ hue list
TEST
[1] Hue Lamp 1
TEST
[2] Hue Lamp 2
TEST
[3] Hue Lamp 3
TEST
[4] Hue Lamp 4
TEST
[5] BT Lamp
bradysmacbookpro:rubyhue bradyaturner$ cd
bradysmacbookpro:~ bradyaturner$ hue list
TEST
[1] Hue Lamp 1
TEST
[2] Hue Lamp 2
TEST
[3] Hue Lamp 3
TEST
[4] Hue Lamp 4
TEST
[5] BT Lamp

The installed and development CLI are both picking up changes to the dev code, but at least its consistent, and it works outside the project directory.

bradyaturner commented 10 years ago

Closing this. Reverting the commit fixed the problem. We're still left with the executable problem, but I think we'll just have to live with "bundle exec hue" for now.