cannot find package on travis-ci -golang - build

I'm trying to run a go script as part of the build process. The script imports a 'custom' package. However I get this import error.
The repository name is bis. The script which I run is configbis.go. The package imported configbis.go is mymodule
The project structure is as following:
bisrepo -------
| |
mymodule configbis.go
go run configbis.go
configbis.go:16:2: cannot find package "bisrepo/mymodule" in any of:
/home/travis/.gvm/gos/go1.1.2/src/pkg/bisrepo/mymodule (from $GOROOT)
/home/travis/.gvm/pkgsets/go1.1.2/global/src/bisrepo/mymodule (from $GOPATH)
I've tried to import mymodule in configbis.go as following:
import "mymodule"
import "bisrepo/mymodule"
import "github.com/user/bisrepo/mymodule"
None of them works. I run out of ideas/options ...
I read the the travis-ci documentation and I found it useless.

You could try to add something like that in your .travis.yml:
install:
- go get github.com/user/bisrepo/mymodule

in order to use private repos you must provide a github api auth token (similarly so when deploying go projects which reference private repos on Heroku). You can try adding something like this in your .travis.yml
before_install:
- echo "machine github.com login $GITHUB_AUTH_TOKEN" > ~/.netrc

Related

AWS CDK -- Cannot find module '#aws-cdk/aws-ec2'

I just started playing around with AWS CDK yesterday and I found something very weird.
First of all, I'm using TypeScript for my CDK app (I used cdk init --language typescript to generate the project files and I tried to import aws-ec2 module so this is what I did:
import cdk = require('#aws-cdk/core');
import ec2 = require('#aws-cdk/aws-ec2');
export class vpcStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
//.... all other codes go here....
However, when importing the aws-ec2 module this way, I got this error when trying to deploy the stack:
тип Unable to compile TypeScript:
lib/cdk-type_script-stack.ts:2:22 - error TS2307: Cannot find module '#aws-cdk/aws-ec2'.
2 import ec2 = require('#aws-cdk/aws-ec2');
~~~~~~~~~~~~~~~~~~
Subprocess exited with error 1
This is very weird because the API docs right here clearly stated that this is how I should import the aws-ec2 module in TypeScript
You need to install the node package before you could import and use it
Execute below on the command line to install npm package for aws-cdk
npm i #aws-cdk/aws-ec2
npm install (for install lib)
npm run build (for compile your code)
After that, you can run:
cdk synth
cdk deploy
You may have a version of npm that is incompatible with the version of #aws-cdk/pipelines as explained here: https://github.com/aws/aws-cdk/issues/13541#issuecomment-801606777
In addition to #juned-ashan 's answer, verify that you are installing the correct module version that corresponds to your cdk version (and other cdk modules installed).
For example:
$ npm install --save #aws-cdk/aws-ec2#1.10.0
Note: not enough points to add this as a comment in Juned's answer.

AWS Lambda Python 3.7 :Unable to import module 'lambda_function': Missing required dependencies ['numpy']

Same code is working in my local machine, however getting the below error when I tried to test in the AWS Lambda:
Unable to import module 'lambda_function': Missing required dependencies ['numpy']
You need to download the packages from pypi.org and include them on the zip file that contains both, the code in a py file and the packages. Find a more detailed description here https://www.protos-technologie.de/en/2020/07/02/dependency-management-for-aws-lambda/.

nltk download not working inside docker for a django service

I am trying to launch a django service using docker which uses nltk library.
In the dockerfile I have called a setup.py which calls nltk.download. According to the logs I see during building the docker image this step runs successfully.
But when I run the docker image and try to connect to my django service, I get the error saying that nltk.download hasn't happened yet.
Dockerfile code -
RUN . ${PYTHON_VIRTUAL_ENV_FOLDER}/bin/activate && python ${PYTHON_APP_FOLDER}/setup.py
setup.py code -
import nltk
import os
nltk.download('stopwords', download_dir=os.getcwd() + '/nltk_data/')
nltk.download('wordnet', download_dir=os.getcwd() + '/nltk_data/')
Error:
**********************************************************************
Resource stopwords not found.
Please use the NLTK Downloader to obtain the resource:
>>> import nltk
>>> nltk.download('stopwords')
Searched in:
- '/root/nltk_data'
- '/usr/share/nltk_data'
- '/usr/local/share/nltk_data'
- '/usr/lib/nltk_data'
- '/usr/local/lib/nltk_data'
- '/usr/src/venv/nltk_data'
- '/usr/src/venv/share/nltk_data'
- '/usr/src/venv/lib/nltk_data'
**********************************************************************
Any idea what is wrong here?
Also, the same code works when I run it without docker.
Having faced that same problem before and having done almost the same thing you did, I'd assume what you're missing here is configuring the nltk.data.path by adding to the path wherever your os.getcwd() is.
Thanks for the post and it fixed my issue as well!!!!
I got the same issue that punkt does exit in docker:
/root/nltk_data/tokenizers/punkt
But when my app tried to reach it, Docker kept complaining the resource couldn't be found.
Inspired by your post, I added:
ENV NLTK_DATA /root/nltk_data/
ADD . $NLTK_DATA
But still got the same error message. So I tried this:
ENV NLTK_DATA /nltk_data/
ADD . $NLTK_DATA
I didn't know why I wanted to remove /root from the path but it worked!
My app is using Flask and uWSGI, so I guess maybe this is an issue for Django and Flask? Thanks anyway!

golang test for sub directories fails

In my use case I am setting up a single go test which runs all _test.go in all packages in the project folder. I tried to achieve this using $go test ./... from the src folder of the project
/project-name
/src
/mypack
/dao
/util
When I try to run the test it is asking to install the packages which are used in the imported packages. For example if I import "github.com/go-sql-driver/mysql", it might have used another package github.com/golang/protobuf/proto. I did not manually import the proto package. The application runs without manually importing the inner package. But when I run the tests it fails. But individual package test succeeded. Do I have to install all the packages in the $go test ./... error manually?
Could anyone help me on this?
You need to run go get -t ./... first to get all test deps.
From the go test -h:
The -t flag instructs get to also download the packages required to
build the tests for the specified packages.

Cannot find module "laravel-echo"

I am learning to configure Laravel Echo Socket.js and following an article here
Code in bootstrap.js is below
import Echo from "laravel-echo"
window.Echo = new Echo({
broadcaster: 'socket.io',
host: window.location.hostname + ':6001'
});
When I run the above code, it says, Cannot find module "laravel-echo"
I am not using pusher and redis. In the above reference page, I think, there is no installation guidelines given for only socket.io
Can somebody explain if I am missing anything?
I solved the same problem installing the following packages:
npm install --save laravel-echo pusher-js
I needed to install below packages.
npm install -g laravel-echo-server
then following the step by step instruction as give here
Finally put below code before any js file.
<script src="http://{{ Request::getHost() }}:6001/socket.io/socket.io.js"></script>
the issue is here:-
import Echo from "laravel-echo"
you will write it as:-
import Echo from 'laravel-echo';