When I update my composer to add yii2-solr extension to my project, I encounter with an error like below:
The "yiisoft/yii2-composer" plugin requires composer-plugin-api 1.0.0, this *WILL* break in the future and it should be fixed ASAP (require ^1.0 for example).
The "fxp/composer-asset-plugin" plugin requires composer-plugin-api 1.0.0, this *WILL* break in the future and it should be fixed ASAP (require ^1.0 for example).
PHP Fatal error: Call to undefined method Fxp\Composer\AssetPlugin\Package\Version\VersionParser::parseLinks() in /root/.composer/vendor/fxp/composer-asset-plugin/Repository/VcsPackageFilter.php on line 272
Fatal error: Call to undefined method Fxp\Composer\AssetPlugin\Package\Version\VersionParser::parseLinks() in /root/.composer/vendor/fxp/composer-asset-plugin/Repository/VcsPackageFilter.php on line 272
before that I've ran composer self-updatebut still not work and when I want to run
composer global require "fxp/composer-asset-plugin:1.0.1"
again the above error shown.
This is my composer.json file content:
{
"name": "yiisoft/yii2-app-basic",
"description": "Yii 2 Basic Project Template",
"keywords": ["yii2", "framework", "basic", "project template"],
"homepage": "http://www.yiiframework.com/",
"type": "project",
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/yiisoft/yii2/issues?state=open",
"forum": "http://www.yiiframework.com/forum/",
"wiki": "http://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2"
},
"minimum-stability": "stable",
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": ">=2.0.5",
"yiisoft/yii2-bootstrap": "*",
"yiisoft/yii2-swiftmailer": "*",
"filsh/yii2-oauth2-server": "*",
"johnitvn/yii2-rbac-plus": "*",
"yiisoft/yii2-sphinx": "^2.0",
"yiisoft/yii2-solr": "*"
},
"require-dev": {
"yiisoft/yii2-codeception": "*",
"yiisoft/yii2-debug": "*",
"yiisoft/yii2-gii": "*",
"yiisoft/yii2-faker": "*"
},
"config": {
"process-timeout": 1800
},
"scripts": {
"post-create-project-cmd": [
"yii\\composer\\Installer::postCreateProject"
]
},
"extra": {
"yii\\composer\\Installer::postCreateProject": {
"setPermission": [
{
"runtime": "0777",
"web/assets": "0777",
"yii": "0755"
}
],
"generateCookieValidationKey": [
"config/web.php"
]
},
"asset-installer-paths": {
"npm-asset-library": "vendor/npm",
"bower-asset-library": "vendor/bower"
}
}
}
How can I fix this error?
Thanks.
1) Remove old version of Composer Asset Plugin:
composer global remove "fxp/composer-asset-plugin"
2) Install newer version. Recommended version for installation is now (by the moment of writing this) 1.1.1 (see official docs).
composer global require "fxp/composer-asset-plugin:~1.1.1"
I'd even recommend to use:
composer global require "fxp/composer-asset-plugin:*"
3) Run composer install in your project folder. In case of errors, delete vendor folder contents and composer.lock file and run composer install again.
If arogachev's answer doesn't exactly work for you, here is a quick fix.
Manually delete the vendor folder in your global composer installation. The folder to delete for eg. on ubuntu : /home/user/.composer/vendor
Install the newer version of the plugin
composer global require "fxp/composer-asset-plugin:*"
That should be all. You will get all your files back and you can continue
Bower-Asset skip way:
You can require yidas/yii2-composer-bower-skip before yiisoft/yii2 in composer.json file:
"require": {
"php": ">=5.4.0",
"yidas/yii2-composer-bower-skip": "~2.0.0",
"yiisoft/yii2": ">=2.0.5",
"yiisoft/yii2-bootstrap": "*",
...
Then run composer update.
This case is for that you don't need the update for Bower.
See https://github.com/yidas/yii2-composer-bower-skip
Rollback composer to 1.x version - the said plugin does not work (yet) with composer 2.x (as discussed here):
sudo composer self-update --rollback
Related
I've just setup Nerdbank.GitVersionning in my project and I have the same setup as Dapper
Here is my version.json
{
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "0.1.0-alpha.{height}",
"assemblyVersion": "0.1.0.0",
"publicReleaseRefSpec": [
"^refs/heads/master$",
"^refs/tags/v\\d+\\.\\d+"
],
"nugetPackageVersion": {
"semVer": 2
},
"cloudBuild": {
"buildNumber": {
"enabled": true,
"setVersionVariables": true
}
}
}
If I do nbgv get-version:
Version: 0.1.0.1
AssemblyVersion: 0.1.0.0
AssemblyInformationalVersion: 0.1.0-alpha.1+021de4e5ee
NuGet package Version: 0.1.0-alpha.1
NPM package Version: 0.1.0-alpha.1
Here is Dapper's version.json
{
"version": "1.50.8-alpha.{height}",
"assemblyVersion": "1.50.0.0",
"publicReleaseRefSpec": [
"^refs/heads/master$",
"^refs/tags/v\\d+\\.\\d+"
],
"nugetPackageVersion": {
"semVer": 2
},
"cloudBuild": {
"buildNumber": {
"enabled": true,
"setVersionVariables": true
}
}
}
If I do nbgv get-version:
Version: 1.50.8.23
AssemblyVersion: 1.50.0.0
AssemblyInformationalVersion: 1.50.8-alpha.23+e7020b2bde
NuGet package Version: 1.50.8-alpha.23.e7020b2bde
NPM package Version: 1.50.8-alpha.23.e7020b2bde
Any idea on why there is a difference on Nuget & NPM package version?
I suspect you are in the master branch in your repo, and not in master in the Dapper repo. That's why the git commit ids are being dropped from the NuGet / NPM package version strings. According to https://github.com/AArnott/Nerdbank.GitVersioning/blob/master/doc/versionJson.md:
The publicReleaseRefSpec field causes builds out of certain branches or tags to automatically drop the -gabc123 git commit ID suffix from the version, making it convenient to build releases out of these refs with a friendly version number that assumes linear versioning.
I'm currently using create-react-app to bootstrap one of my projects. Basically, I'm trying to set up paths in tsconfig.json by adding these to the default tsconfig.json generated by create-react-app:
"baseUrl": "./src",
"paths": {
"interfaces/*": [
"common/interfaces/*",
],
"components/*": [
"common/components/*",
],
},
However, every time I run yarn start which basically runs react-scripts start, it deletes my changes and generates the default configurations again.
How can I tell create-react-app to use my custom configs?
I was able to do this by using advice from this issue.
Put the configuration options react scripts likes to remove in a separate file (e.g. paths.json) and reference it from tsconfig.json via the extends directive.
paths.json:
{
"compilerOptions": {
"baseUrl": "./src",
"paths": {
"interfaces/*": [ "common/interfaces/*"],
"components/*": [ "common/components/*"],
}
}
}
tsconfig.json
{
"extends": "./paths.json"
...rest of tsconfig.json
}
Create React App does not currently support baseUrl. However there is a workaround...to setup baseUrl for both webpack and the IDE you have to do the following:
Create a .env file with the following code:
NODE_PATH=./
Create a tsconfig.paths.json file with the following code inside:
{
"compilerOptions": {
"baseUrl": "src",
"paths": {
"src/*": ["*"]
}
}
}
Add the following line to tsconfig.json
{
"extends": "./tsconfig.paths.json",
...
}
You can't and I am unsure when you will be able to. I have been trying to use baseUrl and paths so I can avoid relative imports but as you can see they are intentionally removing certain values. The "(yet)" is encouraging but (sigh) who knows when they will officially be supporting it. I recommend subscribing to this github issue to be alerted if/when this changes.
The following changes are being made to your tsconfig.json file:
- compilerOptions.baseUrl must not be set (absolute imports are not supported (yet))
- compilerOptions.paths must not be set (aliased imports are not supported)
If you are using react-scripts 4.0.0 like me then all you need to do is remove the line (around line 160 on my end):
paths: { value: undefined, reason: 'aliased imports are not supported' }
from the file node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js
I was able to straight up add my baseUrl and paths config to my tsconfig.json file like so:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"#domain/*": ["../src/domain/*"],
},
}
}
and finally compile and move on with my life.
Per usual, YMMV. Please test your stuff. This is obviously a hack but it worked for me so I'm posting here in case it helps someone.
Here's a patch if you feel like sharing with your team:
diff --git a/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js b/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js
index 00139ee..5ccf099 100644
--- a/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js
+++ b/node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js
## -156,7 +156,8 ## function verifyTypeScriptSetup() {
: 'react',
reason: 'to support the new JSX transform in React 17',
},
- paths: { value: undefined, reason: 'aliased imports are not supported' },
+ // Removed this line so I can add paths to my tsconfig file
+ // paths: { value: undefined, reason: 'aliased imports are not supported' },
};
Edit
Per #Bartekus thoughtful suggestion in the comments thread I'm adding information on the package I use when I need to add (possibly) temporary changes like these to an npm package: patch-package
The package essentially provides a way to make changes to a package in a cleaner way. Especially when you consider collaboration it becomes very cumbersome to directly change an npm file and move on. The next time you update that package or even when you start developing in a new machine and run npm install your changes will be lost. Also, if you have teammates working on the same project they would never inherit the changes.
In essence you go through the following steps to patch a package:
# fix a bug in one of your dependencies
vim node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js
# run patch-package to create a .patch file
npx patch-package react-scripts
# commit the patch file to share the fix with your team
git add patches/react-scripts+4.0.0.patch
git commit -m "Enable aliased imports in react-scripts"
Next time someone checks out the project and installs it, the patch will be applied automatically due to a post-install script you add during set up:
"scripts": {
+ "postinstall": "patch-package"
}
See up to date instructions in the package's documentation
I had a similar issue to this general problem (CRA overwrites "noEmit": false in my tsconfig.json of a React library I'm working on where I have two separate builds, one for local development, and another to build the production library with typings). Simple solution: use sed in a postbuild script in the package.json. For example: In-place edits with sed on OS X .
{
...
"scripts": {
...
"postbuild": "sed -i '' 's/{THING CRA IS REPLACING}/{WHAT YOU ACTUALLY WANT}/g' tsconfig.json # CRA is too opinionated on this one.",
...
}
...
}
This approach, however, is not cross-platform (unlike how rimraf is the cross-platform alternative to rm -rf).
For me, the problem was with VSCode using an older version of typescript (4.0.3), while the typescript version shipped with the project is (4.1.2).
The following did the trick for me:
Go to the command palette CTRL+Shift+P.
Choose "TypeScript: Select a TypeScript Version...".
Choose "Use workspace Version".
On Botpress (with react-scripts 4.0.3), we use a combination of 2 tricks to use paths without ejecting or patching the code. As Glenn and Microcipcip said, the first step is to extend the tsconfig.json file
tsconfig.path.json
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"~/*": ["src/*"],
"common/*": ["../bp/src/common/*"]
}
}
}
tsconfig.json
{
...
"extends": "./tsconfig.paths.json"
}
Then to make it work in the background, use the package react-app-rewired. It allows to make slight adjustments to the webpack configuration without actually ejecting CRA.
config-overrides.js
module.exports = {
webpack: (config, env) => {
config.resolve.alias['common'] = path.join(__dirname, '../bp/dist/common')
config.resolve.alias['~'] = path.join(__dirname, './src')
}
}
To see the full code, you can check the github repository https://github.com/botpress/botpress/tree/master/packages/ui-admin
For macOS this workaround should work.
package.json
"scripts": {
"start": "osascript -e 'tell app \"Terminal\" to do script \"cd $PATH_TO_REACT_APP && node ./setNoEmitFalse\"' && react-scripts start",
...
},
...
setNoEmitFalse.js
const fs = require('fs');
const { sleep } = require('sleep')
const path = './tsconfig.json'
const run = async () => {
sleep(2)
const tsconfig = fs.readFileSync(path, 'utf-8');
const fixed = tsconfig.replace('"noEmit": true', '"noEmit": false');
fs.writeFileSync(path, fixed)
}
run()
The execution of the javascript file in a separate terminal (osascript) provides the normal output for react-scripts in the original terminal.
Go to node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js and replace
const compilerOptions = {
...
};
by
const compilerOptions = { };
I have a question whichone version should I use?
I started with Symfony 3.4 LTS which requires FOSUserBundle ^2.0. To use SonataUserBundle with FOSUserBundle I need to use ^4.0. In 4.0 there's no user profile things. I need to implement them all or I missed something?
There are only one way to use SonataUserBundle of version 4.x-dev but... with special commit reference (3dd68a6aae95cffe6a4275d68c27d2766d8b93f7) and FosUserBundle of version 2.0.1.
I know for sure, that this works for Symfony 3.3.2
Here is example of composer.json and composer.lock:
Composer.json
"require": {
...
"friendsofsymfony/user-bundle": "v2.0.1",
...
"sonata-project/admin-bundle": "3.18.2",
"sonata-project/doctrine-orm-admin-bundle": "3.1.4",
"sonata-project/user-bundle": "4.x-dev",
...
"symfony/symfony": "^3.3.2",
...
},
Compose.lock (sonata user bundle part)
{
"name": "sonata-project/user-bundle",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/sonata-project/SonataUserBundle.git",
"reference": "3dd68a6aae95cffe6a4275d68c27d2766d8b93f7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sonata-project/SonataUserBundle/zipball/3dd68a6aae95cffe6a4275d68c27d2766d8b93f7",
"reference": "3dd68a6aae95cffe6a4275d68c27d2766d8b93f7",
"shasum": ""
},
...
To use SonataUserBundle 4.x with Symfony 3.4 (and more specifically PHP 5.6/7.0), you can use "runroom/sonata-user": "4.x-dev" (see https://github.com/Runroom/SonataUserBundle), which is a fork of one of Sonata's team member to restore PHP 5.6/7.0 compatibility for SonataUserBundle.
I am creating a Zeppelin Helium Visualization and I need to add one local dependency. I am working on Zeppelin 0.8.snapshot version.
I am not able to do it, I have tried adding in the following manner. I tried using "*" for my modules, I also tried providing relative path without success.
My module has to be added locally.
{
"name": "zeppelin_helium_xxx",
"description" : "xxx",
"version": "1.0.0",
"main": "heliumxxx",
"author": "",
"license": "Apache-2.0",
"dependencies": {
"mymodule": "*",
"zeppelin-tabledata": "*",
"zeppelin-vis": "*"
}
}
Currently, Zeppelin doesn't support the relative path in helium json. You need to provide the absolute path for the artifact field.
Here is one example from https://github.com/1ambda/zeppelin-highcharts-columnrange/blob/master/zeppelin-highcharts-columnrange.json
{
"type" : "VISUALIZATION",
"name" : "zeppelin-highcharts-columnrange",
"version" : "local",
"description": "Column range chart using highcharts library",
"artifact" : "/Users/lambda/github/1ambda/zeppelin-highcharts-columnrange",
"icon": "<i class=\"fa fa-align-center\"></i>"
}
Additionally, there is a JIRA ticket for this issue.
https://issues.apache.org/jira/browse/ZEPPELIN-2097
And you might see an incorrect error message when you load local helium packages.
ERROR [2017-03-05 12:54:14,308] ({qtp1121647253-68}
HeliumBundleFactory.java[buildBundle]:131) - Can't get module name and version of package zeppelin-markdown-spell
Then check the artifact value again. Probably, it's invalid.
https://issues.apache.org/jira/browse/ZEPPELIN-2212
I'm using Cakephp and Miles's uploader plugin. I've got the composer plugin installed, and I'm using the latest copy of wamp. Fileinfo extension is enabled in php. when I try to update using composer it doesn't - it just uses a previous version. If I change the json file to force an update to the latest version I get and error message telling me the ext-fileinfo is not present - but it is.............
I need to get the lastest version as I have an error which shows up on my webserver which is running php 5.3 (wamp is using 5.4)
Additional info:-
The main composer.json is :-
{"config":{"vendor-dir":"Vendor"},
"require": {
"mjohnson/uploader": "4.3.*",
"mjohnson/utility": "1.5.*",
"mjohnson/decoda": "*",
"titon/utility": "*",
"cakephp/debug_kit": "2.2.*"
}
}
I'm expecting mjohnson/uploader to update (
a sub set composer.JSON is held in the uploader package :-
{
"name": "mjohnson/uploader",
"type": "cakephp-plugin",
"description": "File uploader and validation plugin for CakePHP.",
"keywords": ["cakephp", "uploader", "plugin", "file", "validation", "attachment"],
"homepage": "http://milesj.me/code/cakephp/uploader",
"license": "MIT",
"authors": [
{
"name": "Miles Johnson",
"homepage": "http://milesj.me"
}
],
"require": {
"php": ">=5.3.3",
"ext-curl": "*",
"ext-mbstring": "*",
"composer/installers": "*",`enter code here`
"mjohnson/transit": ">=1.4"
},
"support": {
"source": "https://github.com/milesj/Uploader"
}
}
and I would also have expected mjohnson/transit to have updated
I had a similar problem with ext-fileinfo and ext-curl on Windows 7. My problem was the path variable causing the wrong php.exe to be executed by composer. If php -m from the command line shows ext-fileinfo is not present that could be your problem too.