Composer->does not contain valid JSON - json

Using: composer search 'tokens'command the IDE threw this error. I can't search neither download packages from: packagist.org
C:\ProgramData\ComposerSetup\bin\composer.bat search fosuserbundle
[Seld\JsonLint\ParsingException]
"http://packagist.org/packages.json" does not contain valid JSON
Parse error on line 1:
<HTML><HEAD><meta h
^
Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
search [-N|--only-name] tokens1 ... [tokensN]

In windows machine, I've followed all these steps and get back in a correct behaviour (my problem was happening with composer require, but I believe it's the same as you described using composer search or if we would be using composer install for example. So, let´s see the steps:
Update composer (`composer self-update)
Disable IPV6 (as pointed in official docs, misconfigured IPV6 setting is a common source of issues)
Delete (or rename to repo_temp) your folder %LOCALAPPDATA%\Composer\repo (in order to have all contents updated)
Delete (or rename to vendor_temp) your vendor folder inside your project (in order to force composer to download all components again, and as pointed in this thread comment)
After doing these steps, in my, case, the issue was gone!
Message before (ERROR):
> composer require ...
...
"https://packagist.org/packages.json" does not contain valid JSON
Parse error on line 1:
▼\\\\\\♥��ݎ♀���
^
Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
https://packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date
Message after doing the steps (OK)!:
> composer require ...
...
Writing lock file
Generating autoload files

Related

Not allow duplicate tags in yml file

I am trying to validate my sample yml using yml schema file.
a.yml data file:
test:
version1
test:
version1
s.yml schema file:
type: map
mapping:
test:
type: str
required: yes
unique: yes
In my perl code i am using YML inbuilt module and validate my data file with schema file as followed:
eval { validate(YAML::LoadFile(s.yml), YAML::LoadFile(a.yml)) };
I was expecting to fail the validation because of having duplicate tags 'type:'. Is there a way to not allow duplicate tags in yml file while validating against schema schema.
I notice that loading is failing with warning:
Name "YAML::SortKeys" used only once: possible typo at test.plline 21.
YAML Warning: Duplicate map key found. Ignoring.
Code: YAML_LOAD_WARN_DUPLICATE_KEY
Line: 1
Document: 1
Currently i am using 'use warnings FATAL => qw(all);', Still my script is passing. Not sure why it still pass with warnings.
Can we make it Error?
YAML::PP forbids duplicate keys by default (*).
use YAML::PP;
my $yaml = <<"EOM";
foo: a
foo: b
EOM
YAML::PP::Load($yaml);
__END__
Duplicate key 'foo' at /.../YAML/PP/Parser.pm line 61.
You are using YAML.pm, which is not recommened anymore, as it was written for YAML 1.0 and also has other problems.
(*) YAML::PP forbids duplicate keys since version 0.027. Before they were ignored.

Setting Jenkins build name from package.json version value

I want to include the value of the "version" parameter in package.json as part of the Jenkins build name.
I'm using the Jenkins Build Name Setter plugin - https://wiki.jenkins-ci.org/display/JENKINS/Build+Name+Setter+Plugin
So far I've tried to use PROPFILE syntax in the "Build name macro template" step:
${PROPFILE,file="./mainline/projectDirectory/package.json",property="\"version\""}
This successfully creates a build, but includes the quotes and comma surrounding the value of the version property in package.json, for example:
"0.0.1",
I want just the value inside returned, so it reads
0.0.1
How can I do this? Is there a different plugin that would work better for parsing package.json and getting it into the template, or should I resort to some sort of regex for removing the characters I don't want?
UPDATE:
I tried using token transforms based on reading the Token Macro Plugin documentation, but it's not working:
${PROPFILE%\"\,#\",file="./mainline/projectDirectory/package.json",property="\"version\""}
still just returns
However, using only one escaped character and only one of # or % works. No other combinations I tried work.
${PROPFILE%\,,file="./mainline/projectDirectory/package.json",property="\"version\""}
which returns "0.0.1" (comma removed)
${PROPFILE#\"%\"\,,file="./mainline/projectDirectory/package.json",property="\"version\""}
which returns "0.0.1", (no characters removed)
UPDATE:
Tried to use the new Jenkins Token Macro plugin's JSON macro with no luck.
Jenkins Build Name Setter set to update the build name with Macro:
${JSON,file="./mainline/pathToFiles/package.json",path="version"}-${P4_CHANGELIST}
Jenkins build logs for this job show:
10:57:55 Evaluated macro: 'Error processing tokens: Error while parsing action 'Text/ZeroOrMore/FirstOf/Token/DelimitedToken/DelimitedToken_Action3' at input position (line 1, pos 74):
10:57:55 ${JSON,file="./mainline/pathToFiles/package.json",path="version"}-334319
10:57:55 ^
10:57:55
10:57:55 java.io.IOException: Unable to serialize org.jenkinsci.plugins.tokenmacro.impl.JsonFileMacro$ReadJSON#2707de37'
I implemented a new macro JSON, which takes a file and a path (which is the key hierarchy in the JSON for the value you want) in token-macro-2.1. You can only use a single transform per macro usage.
Try the token transformations # and % (see Token-Makro-Plugin):
${PROPFILE#"%",file="./mainline/projectDirectory/package.json",property="\"version\""}
(This will only help if you are using pipelines. But for what it's worth,..)
What works for me is a combination of readJSON from the Pipeline Utility Steps plugin and directly setting currentBuild.displayName, thusly:
script {
// readJSON from "Pipeline Utility Steps"
def packageJson = readJSON file: 'package.json'
def version = packageJson.version
echo "Setting build version: ${packageJson.version}"
currentBuild.displayName = env.BUILD_NUMBER + " - " + packageJson.version
// currentBuild.description = "other cool stuff"
}
Omitting error handling etc obvs.

No files included in stash exception

I am using stash command in groovy script. I am getting:
Caught: hudson.AbortException: No files included in stash
However the logs before the exception says:
Stashed 1 file(s)
[Pipeline] stash
Stashed 1 file(s)
can you please advise
I'm guessing based on your log you're doing more than one stash, perhaps you do have one that doesn't have any files, in that case you need allowEmpty: true
stash allowEmpty: true, includes: 'foo', name: 'bar'
I had this problem. I was making a mistake by specifying multiple files by name without comma separator. Correct way is:
stash includes: "a.bin,a.log", name: "<name>"
Please use "Pipeline Syntax" link to generate command and read description of fields you want to use.

Setting pylintrc path in pylinter for Sublime Text

I've got Sublime Text 2 (+ the pylinter package) and pylint installed, but can't get the pylint_path setting to work; my Pylinter.sublime-settings file looks like:
{
"verbose":true,
"message_stay": true,
"pylint_path": "Z:\\python\\pylintrc"
}
but when I run pylint I get the following output:
- PyLinter: Verbose is True
- PyLinter: Running Pylinter on Z:\TestProject\test.py
- PyLinter: Current PYTHONPATH is ''
- PyLinter: Updated PYTHONPATH is ''
- PyLinter: Running command with Pylint (1, 4, 1)
- PyLinter: python Z:\python\pylintrc --reports=n --msg-template={path}:{line}:{msg_id}:{msg} --disable=C0303 Z:\TestProject\test.py
error: Fatal pylint error:
SyntaxError: invalid syntax
- PyLinter: No errors found
but I've put errors in to prove to myself it works (or doesn't..)! If I remove the pylint_path setting, it works and the errors do get reported. (For completion, I've tried Z:/TestProject/test.py and Z:\TestProject\test.py too, and get the same result each time)
This was asked a long time ago, but I just stumbled across it from google.
You want to set pylint_rc instead of pylint_path.
From the default settings:
// Full path to the lint.py module in the pylint package
"pylint_path": null,
// Optional full path to a Pylint configuration file
"pylint_rc": null,

dpkg-shlibdeps: error: no dependency information found for

I'm compiling a deb package and when I run dpkg-buildpackage I get:
dpkg-shlibdeps: error: no dependency information found for /usr/local/lib/libopencv_highgui.so.2.3
...
make: *** [binary-arch] Error 2
This happens because I installed the dependency manually. I know that the problem will be fixed if I install the dependency (or use checkinstall), and I want to generate the package anyway because I'm not interested on dependency checking. I know that I can give to dpkg-shlibdeps the option --ignore-missing-info which prevents a fail if dependency information can't be found. But I don't know how to pass this option to dpkg-shlibdeps since I'm using dpkg-buildpackage and dpkg-buildpackage calls dpkg-shlibdeps...
I have already tried:
sudo dpkg-buildpackage -rfakeroot -d -B
And with:
export DEB_DH_MAKESHLIBS_ARG=--ignore-missing-info
as root.
Any ideas?
use:
override_dh_shlibdeps:
dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info
if your rule file hasn't the dh_shlibdeps call in it. That's usually the case if you've
%:
dh $#
as only rule in it ... in above you must use a tab and not spaces in front of the dh_shlibdeps
If you want it to just ignore that flag, change the debian/rules line from:
dh_shlibdeps
to:
dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info
Yet another way, without modifying build scripts, just creating one file.
You can specify local shlib overrides by creating debian/shlibs.local with the following format: library-name soname-version dependencies
For example, given the following (trimmed) ldd /path/to/binary output
libevent-2.0.so.5 => /usr/lib/libevent-2.0.so.5 (0x00007fc9e47aa000)
libgcrypt.so.20 => /usr/lib/libgcrypt.so.20 (0x00007fc9e4161000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007fc9e3b1a000)
The contents of debian/shlibs.local would be:
libevent-2.0 5 libevent-2.0
libgcrypt 20 libgcrypt
libpthread 0 libpthread
The "dependencies" list (third column) doesn't need to be 100% accurate - I just use the library name itself again.
Of course this isn't needed in a sane debian system which has this stuff defined in /var/lib/dpkg/info (which can be used as inspiration for these overrides). Mine isn't a sane debian system.
Instead of merely ignoring the error, you might also want to fix the source of the error, which is usually either a missing or an incorrect package.shlibs or package.symbols file in package which contains the shared library triggering the error.
[1] documents how dpkg-shlibdeps uses the package.shlibs resp. package.symbols, files, [2] documents the format of the package.shlibs and package.symbols files.
[1] https://manpages.debian.org/jessie/dpkg-dev/dpkg-shlibdeps.1.en.html
[2] https://www.debian.org/doc/debian-policy/ch-sharedlibs.html
You've just misspelled your export. It should be like this:
export DEB_DH_SHLIBDEPS_ARGS_ALL=--dpkg-shlibdeps-params=--ignore-missing-info
dpkg-buildpackage uses make to process debian/rules. in this process, dpkg-buildpackage it might call dpkg-shlibdeps.
thus, the proper way to pass modify a part of the package building process is to edit debian/rules.
it's hard to give you any more hints, without seeing the actual debian/rules.
Finally I did it in the brute way:
I edited the script /usr/bin/dpkg-shlibdeps, changing this :
my $ignore_missing_info = 0;
to
my $ignore_missing_info = 1;
You can use this:
dh_makeshlibs -a -n
exactly after dh_install