redirecting STDERR in jruby - jruby

I'm trying to redirect STDERR to a file for a jruby program that runs as a daemon. I've done this in MRI before with no issue, but I seem to be missing some piece of the puzzle in jruby.
log = File.new('/home/my_user/test_log.log', "w")
$stderr.reopen log
$stderr.puts "writing to log!"
require 'some_broken_thing'
log contents in MRI (2.0.0-p0):
/path/to/ruby/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- some_broken_thing (LoadError)
from /path/to/ruby/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from test.rb:5:in `<main>'
writing to log!
log contents in jruby (1.7.4):
writing to log!
I'm just trying to ensure that silly things like broken requires or unmet dependencies get logged somewhere instead of getting fired off to the console. Not sure what I'm doing wrong. When I call $stderr.reopen, the error output from the broken require doesn't show up in the console, which is good, but it never shows up in the file, which isn't so good.

forgot to close this out. As inger pointed out, this was fixed in http://github.com/jruby/jruby/issues/1082

Related

Heroku deployment: 'Cannot find module '...mime.js Please verify package.json has valid "main" entry

I am working on a React app with a MySQLdb and am trying to deploy with Heroku. I have followed a guide closely and am using JAWS DB hook to connect my db to Heroku. I am running into this error when I run the "heroku open" command after pushing to heroku:
"Error: Cannot find module '/app/node_modules/mime/mime.js'. Please verify that the package.json has a valid "main" entry"
My package.json has mime.js installed as a devDependency. I have set the "main" line in my package.json to "index.js" as well.
Repo: https://github.com/AndrewCodesDontYaKnow/ReactCalc
Anyone have any experience with this type of issue? Thanks much.
I just had the same problem with a different module ("telebot" in my case)
I didn't figure out how to fix the issue (if anyone else finds this, I'd also like to know how to fix it), but I got it to work with a work around...
I copied the module source, and put it into my repo, and just used it as a local module...
(in my case I had by my .gitignore file ignore any "lib" folder, it gave me a hard time until i realized the lib folder from the telebot folder is just not getting uploaded to GitHub, and as such not getting to heroku, but after commenting it out, and getting it to upload, the local module worked as intended)
also, I don't think this is an actual answer, but I don't have the rep to comment, so I hope this helps

'[Error] Unable to find or read "package.json" in the CWD. The "release-react" command must be executed in a React Native project folder.'

I've been getting this error while trying to create a script file to automate a little of the codePush deployment process.
Looking at all the information I could find online wasn't helping - In the script I echo'd the PWD to see that I am running the code-push release-react command from the correct location in my .sh file, I am including react-native as a package dependency in my package.json. Everything looked fine, but I was still getting the error.
Since I found the issue but couldn't find anything online to point to what the problem was, I'll post the answer below.
Upon playing with the scripts in my package.json I tried running npm install again to make sure everything was setup properly when I get an error that actually showed me my issue.
The problem was the JSON in my package.json had become corrupted - the syntax wasn't spot on. I had started playing with the json in the file and forgot to revert the changes I made when I finished and had an extra comma.
Now that almost a whole day is gone, I can get back to work.

Cython: recompile modules

I have one quick and very basic question about compiling modules in Cython: I have compiled a couple of modules using distutils and the command "build_ext --inplace". When I make a change to one of these modules, repeating "build_ext --inplace" leads to an error:
fatal error LNK1104: cannot open file 'C:\Users...\PycharmProjects...pyd'
When I close PyCharm and restart it, everything works fine - it seems like the current files cannot be deleted because they're still in use unless I restart everything. Thus, I was wondering if there is a way to avoid the restart and losing all the objects in memory?
Best,
T

Perl can't load SSLeay.dll because LWP::Protocol::https is not installed

For internal messaging the company I work for uses Slack. It allows for a lot of awesome integration with tons of different software and services. I'm making my own bot for sending webhooks to Slack.
I got everything set up and working, I have a Perl script that sends a JSON payload. If I trigger the script manually, everything works flawlessly and my Slack bot sends messages.
However, when the script gets triggered by Finalbuilder (Software for automatic build processing), it it fails.
I get the following response:
501 Can't load 'C:/Strawberry/perl/site/lib/auto/Net/SSLeay/SSLeay.dll' for module Net::SSLeay: load_file:The specified module could not be found (LWP::Protocol::https not installed)
So I figured I needed to install the "LWP::Protocol::https" module. I just opened my cpan client and wrote install LWP::Protocol::https
Still get the error after installing the module.
I wrote test LWP::Protocol:https, which gave the following response:
Running test for module 'LWP::Protocol::https'
Running make for M/MS/MSCHILLI/LWP-Protocol-https-6.06.tar.gz
Checksum for C:\Strawberry\cpan\sources\authors\id\M\MS\MSCHILLI\LWP-Protocol-https-6.06.tar.gz ok
Scanning cache C:\Strawberry\cpan\build for sizes
............................................................................DONE
CPAN.pm: Going to build M/MS/MSCHILLI/LWP-Protocol-https-6.06.tar.gz
Checking if your kit is complete...
Looks good
Writing Makefile for LWP::Protocol::https
Could not read metadata file. Falling back to other methods to determine prerequisites
cp lib/LWP/Protocol/https.pm blib\lib\LWP\Protocol\https.pm
MSCHILLI/LWP-Protocol-https-6.06.tar.gz
C:\Strawberry\c\bin\dmake.EXE -- OK
Running make test
C:\Strawberry\perl\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_harness(0,'blib\lib', 'blib\arch')" t/*.t
t/apache.t ....... ok
t/https_proxy.t .. 1/56 # creating cert for direct.ssl.access
# creating cert for direct.ssl.access
# creating cert for foo
# creating cert for bar
# creating cert for foo
# creating cert for foo
# creating cert for bar
# creating cert for bar
t/https_proxy.t .. ok
All tests successful.
Files=2, Tests=61, 8 wallclock secs ( 0.02 usr + 0.01 sys = 0.03 CPU)
Result: PASS
MSCHILLI/LWP-Protocol-https-6.06.tar.gz
C:\Strawberry\c\bin\dmake.EXE test -- OK
I can trigger my script with windows CMD, or Finalbuilder. Both will work just fine, but when the Finalbuilder project gets activated through Continua CI, I get the "can't load ssleay.dll" error.
I have no clue what to do now. Does anyone know how I can fix the Perl error?
I got this same error while running scripts from IDE, but not from command line (same issue).
My command line was adding these to the path. (These were not globally defined).
c:\perl\perl\bin;c:\perl\sup\bin;c:\perl\c\bin;
But the IDE didn't have these. So same fix should work for FinalBuilder, it is missing the perl path information.
Have you loaded the header files? I don't know what they are for Windows but in Linux, they're called: libssl-dev and zlib1g-dev
I also had this error for awhile. In my case the solution was quite simple. It turned out that I hadn't restarted the SVN service, so when it ran the post-commit.bat file the PATH environment hadn't been updated to reflect the new paths that had been added during the Perl install.
While I was testing I was running from a new console window which had the correct PATH, but as soon as it ran from the batch file via SVN it broke, with exactly the same error you posted.
Same problem with IDE Eclipse, command line fine but error with IDE.
I check the location:
C:\>perldoc -l LWP::Protocol::https
C:\zailperl\perl\vendor\lib\LWP\Protocol\https.pm
And I add it to Environments variables.
I didn't want to reboot my PC so I add the parent path to the IDE.
Right click on project.
enter image description here

Jenkins/Hudson fails when trying to retrieve code from CVS

Trying to configure Jenkins CI. Currently just running it from the .war (eventual intention as a service). Jenkins is aware of the CVS executable (i.e. will read the version [Concurrent Versions System (CVSNT) 2.0.62.1817 (client/server)]).
The .cvspass is not specified, because they apparently do not play nice with CVSNT (which prefers to keep passwords in the registry.) I've specified the password in the job config by using the :pserver:user:passg#server:/dir pattern for CVSROOT, which I found suggested in some places. Regardless of whether I run using that, or :pserver:userg#server:/dir as the CVSROOT I get the blinking red ball, jenkins stuck with a nearly full progress bar for 2 and a half minutes. It then fails. The console output yells with something like
FATAL: hudson.scm.ChangeLogSet.iterator()Ljava/util/Iterator;
java.lang.AbstractMethodError: hudson.scm.ChangeLogSet.iterator()Ljava/util/Iterator;
at hudson.model.AbstractBuild.getCulprits(AbstractBuild.java:282)
at hudson.model.AbstractBuild.getCulprits(AbstractBuild.java:279)
at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:596)
at hudson.model.Run.run(Run.java:1400)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:175)
Both CVSROOTs I'm using provide no trouble with TortoiseSVN. I've found some mention of difficult of logging into SVN from jenkins as a service and related user/system issues, but considering I'm running it from the .war I don't think that's the issue.
EDIT:
Interestingly the console log if I use an invalid user or password recognizes such.
cvs [checkout aborted]: authorization failed: server rejected access to /dir for user FOO
FATAL: CVS failed. exit code=1
Finished: FAILURE
which indicates that Hudson is talking to the CVS server and authenticating, but something else goes wrong.
/EDIT
Cheers
Answer to the question found, thanks to rpetti on #jenkins on freenode. Problem was I had switched between Hudson and Jenkins and there were some incompatible configuration files that were mucking things up. Deleting and recreating the home directory solved the problem.
CVSNT 2.0.62.1817 is very very old and has several known security issues. Please upgrade to the latest 2.8.01.