Bypassing Version Checks
Relevant source files
The following files were used as context for generating this wiki page:
The version check bypass system is a feature designed to circumvent version restrictions within the Cursor application. It employs a two-pronged strategy depending on the detected version of Cursor. For versions older than 0.46.0, it modifies the product.json file to report a newer version. For versions 0.45.0 and newer, it patches core JavaScript files (out/main.js and out/vs/workbench/workbench.desktop.main.js) to alter functionality related to machine ID generation and UI elements.
This functionality is exposed to the user through a menu option in the main interface. The system is designed to be cross-platform, with specific logic to locate necessary files on Windows, macOS, and Linux.
Sources: bypass_version.py, totally_reset_cursor.py:648-655, main.py:461-463
Core Components
The version bypass mechanism is primarily composed of two distinct but related functionalities: product.json modification and JavaScript patching.
product.json Modification
This is the primary method for bypassing version checks on older Cursor installations. The script directly modifies the version string within the product.json file.
Sources: bypass_version.py
Process Flow
The modification process is orchestrated by the bypass_version function. It locates the product.json file, reads its content, checks if the version is below a specific threshold (0.46.0), and if so, updates it to a hardcoded newer version (0.48.7). A backup of the original file is created before any changes are made.
The following diagram illustrates the flow of the bypass_version function.
Sources: bypass_version.py:118-168
File Location Logic
The get_product_json_path function is responsible for locating the product.json file across different operating systems. It checks a series of predefined paths and also consults the config.ini file for user-defined paths.
The logic for finding the path is as follows:
Sources: bypass_version.py:30-94
The specific paths checked are detailed in the table below:
| Operating System | Default Paths Checked |
|---|---|
| Windows | %LOCALAPPDATA%\Programs\Cursor\resources\app\product.json or path from config.ini. |
| macOS | /Applications/Cursor.app/Contents/Resources/app/product.json or path from config.ini. |
| Linux | /opt/Cursor/resources/app/product.json, /usr/share/cursor/resources/app/product.json, /usr/lib/cursor/app/product.json, or extracted AppImage paths. |
Sources: bypass_version.py:30-94
Version Comparison
The script uses a simple version comparison logic. If the current version is less than 0.46.0, it is considered outdated and will be updated.
# bypass_version.py:108-118
def compare_versions(version1, version2):
"""Compare two version strings"""
v1_parts = [int(x) for x in version1.split('.')]
v2_parts = [int(x) for x in version2.split('.')]
for i in range(max(len(v1_parts), len(v2_parts))):
v1 = v1_parts[i] if i < len(v1_parts) else 0
v2 = v2_parts[i] if i < len(v2_parts) else 0
if v1 < v2:
return -1
elif v1 > v2:
return 1
return 0
Sources: bypass_version.py:108-118
JavaScript Patching
For Cursor versions 0.45.0 and newer, a more involved patching mechanism is triggered. This is part of the machine ID reset process and modifies core application files to alter behavior related to identity and UI. This is handled by functions within totally_reset_cursor.py and reset_machine_manual.py.
Sources: totally_reset_cursor.py:333-406, 648-655, reset_machine_manual.py:393-466, 708-715
Patching Execution Flow
The patching process is initiated from the reset_machine_ids function. It checks the Cursor version and, if it's 0.45.0 or higher, it calls patch_cursor_get_machine_id, which in turn calls modify_main_js to perform the file modifications.
This sequence diagram shows the call chain for patching main.js.
main.js Modification
The modify_main_js function applies regular expressions to patch the getMachineId and getMacMachineId functions in out/main.js. The goal is to remove a fallback mechanism, likely forcing the application to use a newly generated machine ID.
The following regex patterns are used:
r"async getMachineId\(\)\{return [^??]+\?\?([^}]+)\}"r"async getMacMachineId\(\)\{return [^??]+\?\?([^}]+)\}"
These patterns find the getMachineId functions and replace their bodies to return a single value, effectively removing the ?? (nullish coalescing) operator and its fallback operand.
Sources: totally_reset_cursor.py:483-486, reset_machine_manual.py:543-546
workbench.desktop.main.js Modification
In addition to main.js, the workbench.desktop.main.js file is also modified to change UI elements. The modify_workbench_js function replaces several string patterns to alter the user interface.
Key modifications include:
- Changing the "Upgrade to Pro" button to a link to the project's GitHub repository.
- Changing the "Pro Trial" badge text to "Pro".
- Hiding toast notifications by adding a
hiddenclass. - Changing the "Auto-select" text to "Bypass-Version-Pin".
Sources: reset_machine_manual.py:476-501
User Interface
The version bypass feature is exposed to the user via the main menu.
| Menu Option | Description | File |
|---|---|---|
| 11 | Bypass Cursor Version Check | main.py |
Sources: main.py:461-463
The text strings used for this feature are defined in the locale files, allowing for localization.
| Key | English Text | File |
|---|---|---|
bypass.starting | Starting Cursor version bypass... | locales/en.json |
bypass.found_product_json | Found product.json: {path} | locales/en.json |
bypass.no_write_permission | No write permission for file: {path} | locales/en.json |
bypass.version_updated | Version updated from {old} to {new} | locales/en.json |
bypass.no_update_needed | No update needed. Current version {version} is already >= 0.46.0 | locales/en.json |
bypass.bypass_failed | Version bypass failed: {error} | locales/en.json |
Sources: locales/en.json:524-543
Conclusion
The version check bypass system is a critical feature for ensuring the tool's compatibility with various versions of the Cursor application. It uses a flexible, two-part approach: a simple JSON version spoof for older builds and a more complex JavaScript patching mechanism for newer builds. This ensures that as the target application evolves, the tool can adapt its methods to maintain functionality, from altering version numbers to modifying core application logic and UI elements.
Sources: bypass_version.py, totally_reset_cursor.py, reset_machine_manual.py