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

CPAN with --version option fetches only the most current version #518

Closed
treydembski opened this issue Aug 7, 2013 · 4 comments
Labels

Comments

@treydembski
Copy link

@treydembski treydembski commented Aug 7, 2013

Trying to package an older version of Fuse, (0.14), but it fails with the error below.

# fpm -s cpan -t rpm --verbose -v 0.14 Fuse
...
Building and testing Fuse-0.15 ... FAIL {:level=>:info}
14 distributions installed {:level=>:info}
! Installing /tmp/package-cpan-build20130807-15903-1lsefxx/module failed. See /root/.cpanm/work/1375866648.15954/build.log for details. Retry with --force to force install it. {:level=>:error}
Process failed: cpanm failed (exit code 1). Full command was:["cpanm", "-L", "/tmp/package-cpan-build20130807-15903-1lsefxx/cpan", "/tmp/package-cpan-build20130807-15903-1lsefxx/module"] {:level=>:error}
@hatt

This comment has been minimized.

Copy link
Contributor

@hatt hatt commented Aug 8, 2013

I ran a bunch of tests in debug mode, the problem seems to be in version = metadata["version"] if version.nil?. For whatever reason it assigns version to metadata["version"] even though it also thinks version is not nil. I tried as below and could actively see the version being set incorrectly but still showing as not nil. Running some tests with IRB and everything came out as expected though, so I'm really confused.

@logger.debug("Version pre-set", :version_nil => version.nil?, :version => version)
version = metadata["version"] if version.nil?
@logger.debug("Version post-set", :version_nil => version.nil?, :version => version)

Edit: so starting to see what is going on, it's using version as a variable when it's being SUPER'd and calling the function from package.rb instead. I'll try submit a pull request tonight.

@kuukunen

This comment has been minimized.

Copy link

@kuukunen kuukunen commented Aug 8, 2013

As far as I can see, the local variable "version" shadows the method "version" (Method: FPM::Package::CPAN(FPM::Package)#version). And because of Ruby's scoping and variable declaration, the interpreter notices the local variable "version" is being declared on the line and inserts bytecode before it to initialize it to nil.

Here's two examples that demonstrate the possible problems with that:
http://ideone.com/5XeZxg
http://ideone.com/AXCty1 (In this one, the initialization to nil happens before the if block)

Fix:
change:
version = metadata["version"] if version.nil?
to:
self.version = metadata["version"] if self.version.nil?

@hatt

This comment has been minimized.

Copy link
Contributor

@hatt hatt commented Aug 8, 2013

The second self isn't required there, but the code is very ambiguous already. I think the best option is to make it more self explanatory by renaming the variable to cpan_version like how the Gem packager does it. In cpan#input we already have a line where self.version = metadata["version"], is doubly confusing because of the shared scope...

hatt added a commit to hatt/fpm that referenced this issue Aug 8, 2013
@hatt hatt referenced this issue Aug 8, 2013
@jordansissel

This comment has been minimized.

Copy link
Owner

@jordansissel jordansissel commented Aug 18, 2013

Fixed by #519

gerbercj pushed a commit to gerbercj/fpm that referenced this issue Feb 27, 2014
gerbercj pushed a commit to gerbercj/fpm that referenced this issue Mar 11, 2014
gerbercj pushed a commit to gerbercj/fpm that referenced this issue Apr 25, 2014
prof-milki pushed a commit to prof-milki/xpm that referenced this issue Dec 18, 2014
prof-milki pushed a commit to prof-milki/xpm that referenced this issue Dec 27, 2014
jordansissel pushed a commit that referenced this issue Apr 24, 2015
jordansissel pushed a commit that referenced this issue Jun 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.