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

Fails to install on Alpine linux #40

Closed
sputnick opened this issue Feb 22, 2017 · 12 comments
Closed

Fails to install on Alpine linux #40

sputnick opened this issue Feb 22, 2017 · 12 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug
Milestone

Comments

@sputnick
Copy link

sputnick commented Feb 22, 2017

I have node-pty working great on my Mac to make a web based terminal but I'm trying to install node-pty on Alpine linux container and it is failing with the error below. Any ideas as to why?

$ npm install --save node-pty

npm WARN package.json [email protected] No README data
npm WARN package.json [email protected] license should be a valid SPDX license expression
|
> [email protected] install /usr/src/node-red/node_modules/node-pty
> node scripts/install.js

make: Entering directory '/usr/src/node-red/node_modules/node-pty/build'
  CXX(target) Release/obj.target/pty/src/unix/pty.o
../src/unix/pty.cc: In function 'Nan::NAN_METHOD_RETURN_TYPE PtyFork(Nan::NAN_METHOD_ARGS_TYPE)':
../src/unix/pty.cc:233:9: error: 'struct termios' has no member named 'c_ispeed'
   term->c_ispeed = B38400;
         ^
../src/unix/pty.cc:234:9: error: 'struct termios' has no member named 'c_ospeed'
   term->c_ospeed = B38400;
         ^
pty.target.mk:96: recipe for target 'Release/obj.target/pty/src/unix/pty.o' failed
make: *** [Release/obj.target/pty/src/unix/pty.o] Error 1
make: Leaving directory '/usr/src/node-red/node_modules/node-pty/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:12)
gyp ERR! System Linux 4.7.3-coreos-r2
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/src/node-red/node_modules/node-pty
gyp ERR! node -v v4.7.0
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok

> [email protected] postinstall /usr/src/node-red/node_modules/node-pty
> node scripts/post-install.js

[email protected] node_modules/node-pty
└── [email protected]
bash-4.3$
@sputnick
Copy link
Author

Where does termios.h come from that it is trying to compile with? Maybe the node version is too old or something? I managed to install on an ubuntu image using latest nodejs but the Alpine root image I need to use only has node versions:
node -v v4.7.0
node-gyp -v v3.4.0

@Tyriar
Copy link
Member

Tyriar commented Feb 22, 2017

I believe termios.h comes from the system libraries which I guess Alpine is missing (or has a different version). I'm not entirely sure, that is legacy stuff I've never touched and am not too experienced with.

I don't think it's related to node/node-gyp.

@sputnick
Copy link
Author

Ok, I'll try and figure it out. Rather not redo everything on Ubuntu and bloat the docker image footprint. I'll post back here if I find out what the issue is.

@sputnick
Copy link
Author

One thing I noticed. I can install pty.js just fine. No build error. Is that part of the code base very different?

@sputnick
Copy link
Author

pty.js doesn't have the same termios struct as you do. If I remove just those two offending lines (setting the baud rate) it builds on Alpine. Are they necessary?
Lines:
https://github.com/Tyriar/node-pty/blob/master/src/unix/pty.cc#L233
https://github.com/Tyriar/node-pty/blob/master/src/unix/pty.cc#L234

@Tyriar
Copy link
Member

Tyriar commented Feb 23, 2017

Looks like it was added in 424842d (from here https://github.com/jeremyramin/pty.js/tree/prebuilt), it would be nice to understand why the change was made in case it fixed some bug.

@Tyriar
Copy link
Member

Tyriar commented Feb 23, 2017

Perhaps your system has the following APIs instead?

int     cfsetispeed(struct termios *, speed_t);
int     cfsetospeed(struct termios *, speed_t);

Perhaps we could use an #if to section off the correct one?

http://pubs.opengroup.org/onlinepubs/7908799/xsh/termios.h.html

@Tyriar
Copy link
Member

Tyriar commented Feb 23, 2017

Looking at https://linux.die.net/man/3/termios, I tried replacing those 2 lines with this which builds and runs demo/fork_demo.js fine on Ubuntu:

cfsetspeed(term, B38400);

Could you give that a try on your OS? Perhaps the current way is hooking into assumed private APIs?

@sputnick
Copy link
Author

Brilliant that works :)

@Tyriar
Copy link
Member

Tyriar commented Feb 23, 2017

Great! I'll make the change 😃

@Tyriar Tyriar closed this as completed in 4ff4571 Feb 23, 2017
@Tyriar Tyriar self-assigned this Feb 23, 2017
@Tyriar Tyriar added the bug Issue identified by VS Code Team member as probable bug label Feb 23, 2017
@Tyriar Tyriar added this to the 0.6.3 milestone Feb 23, 2017
@kirtangajjar
Copy link

Unable to build again on node:8-alpine :(

Getting this warning while build -

> [email protected] install /usr/src/app/node_modules/node-pty
> node scripts/install.js

make: Entering directory '/usr/src/app/node_modules/node-pty/build'
  CXX(target) Release/obj.target/pty/src/unix/pty.o
../src/unix/pty.cc: In function 'void pty_after_waitpid(uv_async_t*)':
../src/unix/pty.cc:519:69: warning: 'v8::Local<v8::Value> Nan::Callback::Call(v8::Local<v8::Object>, int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
   Nan::Callback(cb).Call(Nan::GetCurrentContext()->Global(), 2, argv);
                                                                     ^
In file included from ../src/unix/pty.cc:20:0:
../../nan/nan.h:1596:3: note: declared here
   Call(v8::Local<v8::Object> target
   ^~~~
  SOLINK_MODULE(target) Release/obj.target/pty.node
  COPY Release/pty.node
make: Leaving directory '/usr/src/app/node_modules/node-pty/build'

> [email protected] postinstall /usr/src/app/node_modules/node-pty
> node scripts/post-install.js

and this error while running container -

  return process.dlopen(module, path._makeLong(filename));
                 ^

Error: Error loading shared library /usr/src/app/node_modules/node-pty/build/Release/pty.node: Exec format error
    at Object.Module._extensions..node (module.js:681:18)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/src/app/node_modules/node-pty/lib/unixTerminal.js:22:11)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)

@bakso
Copy link

bakso commented Sep 12, 2018

You should put a .dockerignore in the dirctory. And ignore node_modules to avoid npm install being overwrited by the COPY directive in the Dockerfile.

node_modules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

4 participants