Git Product home page Git Product logo

esy-bash's Introduction

esy-bash

Build Status npm version

Installation utilities for a bash environment - primed for Reason/OCaml

This package is intended to smooth over cases where OCaml packages rely on Unix utilities or a Bash environment.

On Linux and OS X, this package is essentially a no-op. On Windows, we install an isolated cygwin environment, ready to use for OCaml/OPAM, that we use to run a bash shell.

Installation

 npm install

Installation on Windows does the following:

Usage

Command Line

The esy-bash command runs a script in a bash shell. On Linux and OS X, this just uses the default bash shell. On Windows, this delegates to the installed cygwin environment:

esy-bash echo 'HI'

API

An API is also bundled:

const { bashExec } = require("esy-bash")

await bashExec("ls -a")

License

This source code is licensed under the MIT License.

When installing, several other dependencies are downloaded - like Cygwin and the GNU utilities. These are bound by their own license terms, primarily the GPL License

esy-bash's People

Contributors

andreypopp avatar bryphe avatar manasjayanth avatar phated avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

esy-bash's Issues

Ignore user's `.bash_profile`

For esy, with the bootstrapped builds, we hit issues where the users .bash_profile (which initializes the OPAM repo), can collide with our build commands - bringing in parts of the OPAM environment that break the build.

We should have an option or a way to pass-through arguments to bash, to ignore the .bash_profile.

Performance: 'asyncify' postinstall tasks

When we unpack the package, our postinstall is pretty slow - we're synchronously running all of our tasks (restoring hardlinks and symlinks). We should switch these over to use the async APIs and run them in parallel - would be a major speed up on install!

MinGW gcc vs gcc?

What's the intention/difference between the x86_64-w64-mingw32-gcc installed by esy-bash and the normal gcc package you can install with Cygwin?

I'm trying to build CMake from source and it fails because their bootstrap detects Cygwin but then tries to compile (when forced) with mingw.

I'm currently attempting to install gcc with Cygwin and then build CMake from source. Will update with results.

Clean up temporary files

When we execute an esy-bash command, we create a temporary shell script in the temp folder. We should be cleaning these up after execution - at the moment they stick around.

Native EsyBash: 'ls' command doesn't work

With the native version of esy-bash, the ls command doesn't work:

E:\esy-bash\re\_build\default\bin [master ≡ +1 ~0 -0 !]> ./EsyBash.exe ls -a
C:\Users\bryph\AppData\Local\Temp\__esy-bash__79677993__1__.sh: line 2: ls: command not found

However, this works correctly with the node version:

E:\esy-bash [master ≡ +1 ~0 -0 !]> node .\bin\esy-bash.js ls -a
.        .git         __tests__     bin              jest.config.js  package.json       re
..       .gitignore   appveyor.yml  index.js         LICENSE         package-lock.json  README.md
.cygwin  .travis.yml  bash-exec.js  install-opam.sh  node_modules    postinstall.js

It looks like the difference is that the JS version is somehow including /usr/local/bin and /usr/bin` in the PATH, whereas the native version is not. I'm not sure if this is some difference in how we spin up the bash process? We'll need to make sure these are included in the PATH

First run of esy-bash has extraneous output

This causes failures like this the with this build:

error: sha1 checksum mismatch: expected 59ebdbbaedcda123fc7ed8fb2b302b7d819e9a46 but got Copying
  fetching archive:https://registry.npmjs.org/@esy-ocaml/substs/-/substs-0.0.1.tgz#sha1:59ebdbbaedcda123fc7ed8fb2b302b7d819e9a46
esy: exiting due to errors above

(The extra output broke the result parsing!)

Occasional syntax errors in the temp sh file

Sometime __esy-bash__824592099__1__ file has syntax errors like these

mount -c /cygdrive -o binary,noacl,posix=0,user;
cd "C:/Users/user/b-runner/gl/builds/0/xxxxxxxx/ligolang/ligo/_esy/default/store/b/opam__s__tezos_base-842c849a";
"C:/Users/user/AppData/Roaming/npm/node_modules/esy/node_modules/esy-bash/.cygwin/bin/rm.exe" "-rf" "vendors";s";

This is likely happening because the random number collisions in the filename, causing file overwrites. A good solution could be clearing these files after use. They end up getting accumulated in the current state of things.

Reduce verbosity of logging of postinstall tasks

The postinstall task logging is a bit verbose. We should enable it as an option (perhaps as an environment variable - we could follow with whatever convention npm uses for log verbosity?), but we don't necessarily need to log out all the details of the symlink/hardlink restoration by default - especially with #36 .

New release?

I've been trying to build https://github.com/grain-lang/binaryen.ml and it seems that esy-bash is broken on Windows 10, especially when needing to rely on mingw compilers for our C bindings. If I update the esy-bash installation in my esy install, everything works. This requires an attended install otherwise cygwin kills itself during the upgrade.

Can we get a new release of this package that includes the newest cygwin and installed packages?

cc @ManasJayanth

Convert to native reason executable

This code just spins up a process w/ some environment variables - should be feasible to do this as a native reason executable (with much faster perf!)

Way around path translations and /cygdrive mounting

let tmpFileName =
Printf.sprintf(
"__esy-bash__%s__%s__.sh",
string_of_int(Hashtbl.hash(command)),
string_of_int(nonce^),
);
let tempFilePath =
Sys.getenv(Sys.unix ? "TMPDIR" : "TMP") ++ pathDelimStr ++ tmpFileName;
let cygwinSymlinkVar = "CYGWIN=winsymlinks:nativestrict";
let bashCommandWithDirectoryPreamble =
Printf.sprintf(
"mount -c /cygdrive -o binary,noacl,posix=0,user > /dev/null; \ncd \"%s\";\n%s;",
normalizePath(Sys.getcwd()),
command,
);

This is costs time. Can we get native Windows paths understood in the cygwin/msys layer?

Run tests against installed package

We seem some failures due to the unpacking / packing logic (for example, symlinks not being hydrated correctly).

We should run our test suite against the install package, too. We could do an additional run after we've packed and specify the esy-bash root location via an environment variable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.