cloudfoundry/buildpack-packager

Enable to generate build pack on windows 10

houssemFat opened this issue · 7 comments

Hi,
I'm trying to build a custom buildpack based on the cloud founday official documentation.

platform :

  • ruby 2.3.1p112 (2016-04-26 revision 54768) [x64-mingw32]
  • window 10

After installing buildpack-packager gem, i'm try to build my buildpack using buildpack-packager --cached the system crashes

C:/Ruby23-x64/lib/ruby/2.3.0/open3.rb:199:in `spawn': No such file or directory - which zip (Errno::ENOENT)
        from C:/Ruby23-x64/lib/ruby/2.3.0/open3.rb:199:in `popen_run'
        from C:/Ruby23-x64/lib/ruby/2.3.0/open3.rb:95:in `popen3'
        from C:/Ruby23-x64/lib/ruby/2.3.0/open3.rb:258:in `capture3'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/buildpack-packager-2.3.4/lib/buildpack/packager.rb:48:in `check_for_zip'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/buildpack-packager-2.3.4/lib/buildpack/packager.rb:18:in `package'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/buildpack-packager-2.3.4/bin/buildpack-packager:78:in `<top (required)>'
        from C:/Ruby23-x64/bin/buildpack-packager:23:in `load'
        from C:/Ruby23-x64/bin/buildpack-packager:23:in `<main>'

Is it a system dependencies problem (spawn ...) ?
Thank you !

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/136551279

The labels on this github issue will be updated when the story is started.

Hello!

Thanks for asking this question. The error message you're seeing:

No such file or directory - which zip

is coming from this line in buildpack-packager: https://github.com/cloudfoundry/buildpack-packager/blob/master/lib/buildpack/packager.rb#L48

This is because the which command isn't present on Windows; buildpack-packager is only tested and supported on Linux systems (though I believe it also happens to work on OSX).

There is a portable implementation of which in Ruby here:

https://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby/5471032#5471032

which I've seen used in other open-source projects. I'll leave it up to @sclevine to determine whether supporting Windows is something he wants to spend time on, and whether a PR similar to the above link would be accepted.

@flavorjones Thank you for your quick response.
You are right, the errors above are related to defaults commands such which and zip which are not supported by default on windows.
I'm trying to make it works using Cygwin which adds support for zip and others commands .... But i'm facing another issue related to ruby itself under windows.

C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/buildpack-packager-2.3.4/lib/buildpack/packager/package.rb:126:in `download_file': Failed to download file from https://buildpacks.cloudfoundry.org/dependencies/node/node-0.12.16-linux-x64.tgz (RuntimeError)
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/buildpack-packager-2.3.4/lib/buildpack/packager/package.rb:35:in `block in download_dependencies'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/buildpack-packager-2.3.4/lib/buildpack/packager/package.rb:28:in `each'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/buildpack-packager-2.3.4/lib/buildpack/packager/package.rb:28:in `download_dependencies'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/buildpack-packager-2.3.4/lib/buildpack/packager/package.rb:24:in `build_dependencies'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/buildpack-packager-2.3.4/lib/buildpack/packager.rb:25:in `block in package'
        from C:/Ruby23-x64/lib/ruby/2.3.0/tmpdir.rb:89:in `mktmpdir'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/buildpack-packager-2.3.4/lib/buildpack/packager.rb:22:in `package'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/buildpack-packager-2.3.4/bin/buildpack-packager:78:in `<top (required)>'
        from ./../../../../../../Ruby23-x64/bin/buildpack-packager:23:in `load'
        from ./../../../../../../Ruby23-x64/bin/buildpack-packager:23:in `<main>'
Downloading node version 0.12.16 from: https://buildpacks.cloudfoundry.org/dependencies/node/node-0.12.16-linux-x64.tgz

Thank you for your support !

That error message indicates that the following operation fails for buildpack-packager:
curl #{url} -o #{file} -L --fail -f

Where url is "https://buildpacks.cloudfoundry.org/dependencies/node/node-0.12.16-linux-x64.tgz" and file is some file it's trying to save to.

Does running the following command on your system work?

curl https://buildpacks.cloudfoundry.org/dependencies/node/node-0.12.16-linux-x64.tgz -o target-tar.tgz -L --fail -f

Hi @RochesterinNYC ,
Thank you for support.
Yes that's right, Cygwin does'nt include curl by default command and re-installing curl including the curl module fixed this problem.

I retry but it raises a new exception. I think that's about checksum verification.

C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/buildpack-packager-2.3.4/lib/buildpack/packager/package.rb:106:in `ensure_correct_dependency_checksum': uninitialized constant Buildpack::Packager::Package::Digest (NameError)
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/buildpack-packager-2.3.4/lib/buildpack/packager/package.rb:46:in `block in download_dependencies'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/buildpack-packager-2.3.4/lib/buildpack/packager/package.rb:28:in `each'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/buildpack-packager-2.3.4/lib/buildpack/packager/package.rb:28:in `download_dependencies'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/buildpack-packager-2.3.4/lib/buildpack/packager/package.rb:24:in `build_dependencies'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/buildpack-packager-2.3.4/lib/buildpack/packager.rb:25:in `block in package'
        from C:/Ruby23-x64/lib/ruby/2.3.0/tmpdir.rb:89:in `mktmpdir'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/buildpack-packager-2.3.4/lib/buildpack/packager.rb:22:in `package'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/buildpack-packager-2.3.4/bin/buildpack-packager:78:in `<top (required)>'
        from ./../../../../../../Ruby23-x64/bin/buildpack-packager:23:in `load'
        from ./../../../../../../Ruby23-x64/bin/buildpack-packager:23:in `<main>'
Downloading node version 0.10.43 from: https://pivotal-buildpacks.s3.amazonaws.com/concourse-binaries/node/node-0.10.43-linux-x64.tgz
  Using node version 0.10.43 with size 6.0M

  • I also use buildpack-packager with --uncached but the Bluemix cf host failed to compile the buildpack with no clear errors.
    I think i should switch to a linux based os or using VM bosh based to test it locally.
    Any way, thank you for your support 👍 .

@houssemFat It sounds like you've decided on next steps, so we're going to close this issue. Let us know if you have more questions.

Hello,
I know this thread is marked as closed, but can we please clarify if one can build a buildpack on Windows10 system? or it must be done on Linux system only.

Appreciate inputs/direction on this.