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

"inside" broken when running as an executable #174

Open
workergnome opened this issue Sep 29, 2011 · 3 comments
Open

"inside" broken when running as an executable #174

workergnome opened this issue Sep 29, 2011 · 3 comments

Comments

@workergnome
Copy link

I could be missing something here, but

File example

#!/usr/bin/env ruby
require "thor"

class Example < Thor
  include Thor::Actions


  desc "test", "example test script"
  def test
    file = "test.txt"
    inside("test_dir", :verbose => true) do
      run("touch #{file}")
      copy_file file, "test_2.txt"
    end
  end

  protected
  def self.source_root
      File.dirname(__FILE__)
  end

end

Example.start

Doesn't work. It returns:

$ ./example test
inside  test_dir
  run    touch test.txt from "./test_dir"
  Could not find "test.txt" in any of your source paths. Your current source paths are: 
.

File example.thor:

class Example < Thor
  include Thor::Actions

  desc "test", "example test script"
  def test
    file = "test.txt"
    inside("test_dir", :verbose => true) do
      run("touch #{file}")
      copy_file file, "test_2.txt"
    end
  end

  protected
  def self.source_root
      File.dirname(__FILE__)
  end

end

Works as expected.

@polarblau
Copy link

I just came across a similar issue using template and seeing that this is still open I'll tack mine on.

My templates are found fine until I call template within an inside block. When shifting the path relatively, it works again:

def self.source_root
  File.expand_path(File.join('..', 'templates'), File.dirname(__FILE__))
end

# works:
template 'bar', 'bar'

# doesn’t work
empty_directory 'foo'
inside 'foo' do
  template 'bar', 'bar'
end

# works:
empty_directory 'foo'
inside 'foo' do
  template '../bar', 'bar'
end

Am I missing something? — Cheers!

@ddarbyson
Copy link

Old issue, but it still persists. The following does not work:

# doesn’t work
empty_directory 'foo'
inside 'foo' do
  template 'my_tpl.erb', 'bar'
end
Could not find "my_tpl.erb" in any of your source paths. Your current source paths are: 
/home/username/apps/my_thor_project

@ImmaculatePine
Copy link

I have the same issue. Any progress here?

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

No branches or pull requests

4 participants